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

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

[elpa] externals/consult a062a88e63 2/3: Add consult--completion-window-


From: ELPA Syncer
Subject: [elpa] externals/consult a062a88e63 2/3: Add consult--completion-window-p
Date: Tue, 5 Apr 2022 08:57:23 -0400 (EDT)

branch: externals/consult
commit a062a88e63f4037444f55777a3c5a43777670b2e
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add consult--completion-window-p
---
 consult.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/consult.el b/consult.el
index 1b52e93701..35cd531b44 100644
--- a/consult.el
+++ b/consult.el
@@ -928,6 +928,11 @@ When no project is found and MAY-PROMPT is non-nil ask the 
user."
         (lambda (cand) (eq (get-text-property 0 'consult--type cand) 
consult--narrow))
         :keys types))
 
+(defun consult--completion-window-p ()
+  "Return non-nil if the selected window belongs to the completion UI."
+  (or (eq (selected-window) (active-minibuffer-window))
+      (string-match-p "\\`\\*Completions\\*" (buffer-name (window-buffer)))))
+
 (defmacro consult--with-location-upgrade (candidates &rest body)
   "Upgrade location markers from CANDIDATES on window selection change.
 The markers are not upgraded when BODY has finished without a window change."
@@ -936,7 +941,7 @@ The markers are not upgraded when BODY has finished without 
a window change."
     `(let ((,hook (make-symbol "consult--location-upgrade")))
        (fset ,hook
              (lambda (_)
-               (unless (eq (selected-window) (active-minibuffer-window))
+               (unless (consult--completion-window-p)
                  (remove-hook 'window-selection-change-functions ,hook)
                  (mapc #'consult--get-location ,candidates))))
        (unwind-protect
@@ -1118,7 +1123,7 @@ MARKER is the cursor position."
     (fset hook
           (lambda (_)
             ;; Fully initialize previewed files and keep them alive.
-            (unless (eq (selected-window) (active-minibuffer-window))
+            (unless (consult--completion-window-p)
               (let (live-files)
                 (dolist (buf temporary-buffers)
                   (when-let ((file (buffer-file-name buf))



reply via email to

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