]> code.delx.au - gnu-emacs-elpa/commitdiff
ivy.el (ivy-ignore-buffers): New defcustom
authorOleh Krehel <ohwoeowho@gmail.com>
Fri, 29 Jan 2016 09:04:45 +0000 (10:04 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Fri, 29 Jan 2016 09:04:45 +0000 (10:04 +0100)
* ivy.el (ivy--buffer-list): Use `ivy-ignore-buffers'.

Fixes #366

ivy.el

diff --git a/ivy.el b/ivy.el
index 911fede0f7e1ecfe356753aa66e6c5985af433dd..7a3a07cf7b4b8b6f53fbf0150a82c566ea7fe50a 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -2285,21 +2285,31 @@ CANDS is a list of strings."
       (setq ivy--virtual-buffers (nreverse virtual-buffers))
       (mapcar #'car ivy--virtual-buffers))))
 
+(defcustom ivy-ignore-buffers nil
+  "List of regexps matching buffer names to ignore."
+  :type '(repeat regexp))
+
 (defun ivy--buffer-list (str &optional virtual)
   "Return the buffers that match STR.
 When VIRTUAL is non-nil, add virtual buffers."
-  (delete-dups
-   (append
-    (mapcar
-     (lambda (x)
-       (if (with-current-buffer x
-             (file-remote-p
-              (abbreviate-file-name default-directory)))
-           (propertize x 'face 'ivy-remote)
-         x))
-     (all-completions str 'internal-complete-buffer))
-    (and virtual
-         (ivy--virtual-buffers)))))
+  (cl-remove-if
+   (lambda (buf)
+     (cl-find-if
+      (lambda (regexp)
+        (string-match regexp buf))
+      ivy-ignore-buffers))
+   (delete-dups
+    (append
+     (mapcar
+      (lambda (x)
+        (if (with-current-buffer x
+              (file-remote-p
+               (abbreviate-file-name default-directory)))
+            (propertize x 'face 'ivy-remote)
+          x))
+      (all-completions str 'internal-complete-buffer))
+     (and virtual
+          (ivy--virtual-buffers))))))
 
 (defun ivy--switch-buffer-action (buffer)
   "Switch to BUFFER.