emacs: ivy: properly ignore erc-, magit-, and dired-mode buffers
authorAmin Bandali <bandali@gnu.org>
Mon, 26 Aug 2019 23:43:09 +0000 (19:43 -0400)
committerAmin Bandali <bandali@gnu.org>
Mon, 26 Aug 2019 23:43:09 +0000 (19:43 -0400)
.emacs.d/init.el

index 6c17967..4c69e2a 100644 (file)
@@ -608,6 +608,19 @@ For disabling the behaviour for certain buffers and/or modes."
         ivy-use-virtual-buffers t
         ivy-virtual-abbreviate 'abbreviate
         ivy-count-format "%d/%d ")
+
+  (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
+  (defun b/ivy-ignore-buffer-p (str)
+    "Return non-nil if str names a buffer with a major mode
+derived from one of `b/ivy-ignore-buffer-modes'.
+
+This function is intended for use with `ivy-ignore-buffers'."
+    (let* ((buf (get-buffer str))
+           (mode (and buf (buffer-local-value 'major-mode buf))))
+      (and mode
+           (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
+  (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
+
   (ivy-mode 1)
   ;; :custom-face
   ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
@@ -2091,9 +2104,6 @@ https://csclub.uwaterloo.ca/~abandali")
   (erc-server-reconnect-attempts 5)
   (erc-server-reconnect-timeout 3)
   :config
-  (with-eval-after-load 'ivy
-    ;; ignore channel buffer names
-    (add-to-list 'ivy-ignore-buffers "^#"))
   (defun erc-cmd-OPME ()
     "Request chanserv to op me."
     (erc-message "PRIVMSG"