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

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

[elpa] master 1d2bbf6: Improve working of `el-search-kill-left-over-sear


From: Michael Heerdegen
Subject: [elpa] master 1d2bbf6: Improve working of `el-search-kill-left-over-search-buffers'
Date: Sat, 24 Feb 2018 10:02:57 -0500 (EST)

branch: master
commit 1d2bbf6602409a6d83018290e5902f0cca6c679c
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>

    Improve working of `el-search-kill-left-over-search-buffers'
    
    We used to consult the ring elements of el-search-history to identify
    buffers with non-nil el-search--temp-buffer-flag which might still be
    relevant to the user, which was not optimal.  With this change,
    `el-search--pending-search-p' becomes a reliable mean to do that, and
    we can reimplement el-search-kill-left-over-search-buffers to use this
    function instead.
    
    * el-search/el-search.el (el-search--next-buffer): Remove
    `el-search-hl-post-command-fun' from the local binding of
    `post-command-hook' in the old buffer so that
    `el-search--pending-search-p' is guaranteed to return nil there.
    (el-search-kill-left-over-search-buffers): Use
    `el-search--pending-search-p' to identify temporarily opened file
    buffers which we should not kill.
---
 packages/el-search/el-search.el | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index 7592f68..b656851 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -584,17 +584,12 @@ useful for debugging.")
   "The currently active search, an `el-search-object', or nil.")
 
 (defvar-local el-search--temp-buffer-flag nil
-  "Non-nil tags file visiting buffers as temporarily opened for searching."
-  ;; FIXME: maintaining a list of buffers to close would make
-  ;; `el-search-kill-left-over-search-buffers' more efficient.  And
-  ;; could we merge this with `el-search--temp-file-buffer-flag'?
-  )
+  "Non-nil tags file visiting buffers as temporarily opened for searching.")
 
 (defvar-local el-search--temp-file-buffer-flag nil
   "Non-nil tags (file) buffers that should not be presented to the user.
 Buffers flagged this way contain the contents of a file but were
-not created with `find-file-noselect'.  The name of this file is
-used as non-nil value.")
+not created with `find-file-noselect'.")
 
 (defvar el-search--success nil
   "Non-nil when last search command was successful.")
@@ -1134,11 +1129,11 @@ being killed."
   (interactive)
   (dolist (buffer (buffer-list))
     (when (with-current-buffer buffer el-search--temp-buffer-flag)
-      (unless (or (buffer-modified-p buffer)
-                  (and not-current-buffer (eq buffer (current-buffer)))
-                  (cl-some (lambda (search) (eq buffer (el-search-head-buffer
-                                                   (el-search-object-head 
search))))
-                           (ring-elements el-search-history)))
+      (unless (or (and not-current-buffer (eq buffer (current-buffer)))
+                  (and el-search--current-search
+                       (eq buffer (el-search-head-buffer
+                                   (el-search-object-head 
el-search--current-search))))
+                  (with-current-buffer buffer (el-search--pending-search-p)))
         (kill-buffer buffer)))))
 
 
@@ -1320,7 +1315,12 @@ PATTERN and combining the heuristic matchers of the 
subpatterns."
   ;; SEARCH's head accordingly.  When specified, PREDICATE should accept
   ;; a file name or buffer, and we skip all buffers and files not
   ;; fulfilling it.  Return the new buffer to search in or nil if done.
-  (unless keep-highlighting (el-search-hl-remove))
+  (unless keep-highlighting
+    (el-search-hl-remove)
+    ;; Ensure that `el-search--pending-search-p' returns nil in this
+    ;; buffer even when `el-search-hl-post-command-fun' doesn't get a
+    ;; chance to clean up before that call.
+    (remove-hook 'post-command-hook 'el-search-hl-post-command-fun t))
   (let ((original-predicate (or predicate #'el-search-true))
         (heuristic-buffer-matcher
          (el-search-head-heuristic-buffer-matcher (el-search-object-head 
search))))



reply via email to

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