branch: master commit 2877ae13fac87a8c62e88c7ec82ca2f9faca21f8 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (ivy-ignore-buffers): New defcustom * ivy.el (ivy--buffer-list): Use `ivy-ignore-buffers'. Fixes #366 --- ivy.el | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/ivy.el b/ivy.el index 911fede..7a3a07c 100644 --- 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.