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

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

[elpa] externals/consult 9f0be8f: consult-completing-read-multiple: Fix


From: ELPA Syncer
Subject: [elpa] externals/consult 9f0be8f: consult-completing-read-multiple: Fix selections in *Completions* buffer
Date: Wed, 7 Jul 2021 15:57:06 -0400 (EDT)

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

    consult-completing-read-multiple: Fix selections in *Completions* buffer
---
 consult.el | 53 +++++++++++++++++++++++++++++------------------------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/consult.el b/consult.el
index de9d391..acc6479 100644
--- a/consult.el
+++ b/consult.el
@@ -2230,6 +2230,7 @@ See `completing-read-multiple' for the documentation of 
the arguments."
                            (when selected
                              (format " (%s selected): " (length selected)))))))
          (command)
+         (depth (1+ (recursion-depth)))
          (hook (make-symbol "consult--crm-post-command-hook"))
          (wrapper (make-symbol "consult--crm-command-wrapper")))
     (fset wrapper
@@ -2240,38 +2241,42 @@ See `completing-read-multiple' for the documentation of 
the arguments."
                      (call-interactively command)
                      'continue)
               ('nil
-               (let ((item (minibuffer-contents-no-properties)))
-                 (when (equal item "")
-                   (throw 'exit nil))
-                 (delete-minibuffer-contents)
-                 (funcall select-item item)
-                 (funcall update-overlay)
-                 (run-hook-with-args 'consult--completion-refresh-hook 
'reset)))
+               (with-selected-window (active-minibuffer-window)
+                 (let ((item (minibuffer-contents-no-properties)))
+                   (when (equal item "")
+                     (throw 'exit nil))
+                   (delete-minibuffer-contents)
+                   (funcall select-item item)
+                   (funcall update-overlay)
+                   (run-hook-with-args 'consult--completion-refresh-hook 
'reset))))
               ('t (throw 'exit t)))))
     (fset hook (lambda ()
-                 (setq command this-command
-                       this-command wrapper)))
-    (consult--minibuffer-with-setup-hook
+                 (when (= depth (recursion-depth))
+                   (setq command this-command
+                         this-command wrapper))))
+    (unwind-protect
+      (consult--minibuffer-with-setup-hook
         (:append
          (lambda ()
            (when-let (pos (string-match-p "\\(?: (default[^)]+)\\)?: \\'" 
prompt))
              (setq overlay (make-overlay (+ (point-min) pos) (+ (point-min) 
(length prompt))))
              (funcall update-overlay))
-           (add-hook 'pre-command-hook hook nil 'local)
            (run-hooks 'consult--crm-setup-hook)))
-      (funcall select-item
-               (completing-read
-                prompt
-                (lambda (str pred action)
-                  (if (eq action 'metadata)
-                      md
-                    (complete-with-action action candidates str pred)))
-                nil ;; predicate
-                require-match
-                initial-input
-                'consult--crm-history
-                "" ;; default
-                inherit-input-method)))
+        (add-hook 'pre-command-hook hook 90)
+        (funcall select-item
+                 (completing-read
+                  prompt
+                  (lambda (str pred action)
+                    (if (eq action 'metadata)
+                        md
+                      (complete-with-action action candidates str pred)))
+                  nil ;; predicate
+                  require-match
+                  initial-input
+                  'consult--crm-history
+                  "" ;; default
+                  inherit-input-method)))
+      (remove-hook 'pre-command-hook hook))
     (set hist-sym consult--crm-history)
     (when (consp def)
       (setq def (car def)))



reply via email to

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