emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 1c801a0 243/348: Ignore TAGS buffers in swiper-all


From: Oleh Krehel
Subject: [elpa] master 1c801a0 243/348: Ignore TAGS buffers in swiper-all
Date: Sat, 8 Apr 2017 11:04:06 -0400 (EDT)

branch: master
commit 1c801a0eca80138d3080ce71cf5df9ddb74b0219
Author: Wilfred Hughes <address@hidden>
Commit: Wilfred Hughes <address@hidden>

    Ignore TAGS buffers in swiper-all
    
    Factor out the filter logic into a separate function.
    
    Fixes #787
---
 swiper.el | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/swiper.el b/swiper.el
index a0c932e..1e03445 100644
--- a/swiper.el
+++ b/swiper.el
@@ -748,16 +748,23 @@ Run `swiper' for those buffers."
             (swiper--cleanup)
             (swiper--add-overlays (ivy--regex ivy-text))))))))
 
+(defun swiper-all-buffer-p (buffer)
+  "Return non-nil if BUFFER should be considered by `swiper-all'."
+  (let ((major-mode (with-current-buffer buffer major-mode)))
+    (cond
+     ;; Ignore TAGS buffers, they tend to add duplicate results.
+     ((eq major-mode #'tags-table-mode) nil)
+     ;; Always consider dired buffers, even though they're not backed
+     ;; by a file.
+     ((eq major-mode #'dired-mode) t)
+     ;; Otherwise, only consider the file if it's backed by a file.
+     (t (buffer-file-name buffer)))))
+
 ;;* `swiper-all'
 (defun swiper-all-function (str)
   (if (and (< (length str) 3))
       (list "" (format "%d chars more" (- 3 (length ivy-text))))
-    (let* ((buffers (cl-remove-if-not
-                     (lambda (b)
-                       (or (buffer-file-name b)
-                           (eq (with-current-buffer b
-                                 major-mode) 'dired-mode)))
-                     (buffer-list)))
+    (let* ((buffers (cl-remove-if-not #'swiper-all-buffer-p (buffer-list)))
            (re-full (funcall ivy--regex-function str))
            re re-tail
            cands match)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]