branch: externals/consult
commit 70d2588f5dba60cfe607829d039799944d9e9f83
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    consult--project-root: Preserve this-command (Fix #581)
---
 consult.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/consult.el b/consult.el
index 30e1993b17..c1e7009240 100644
--- a/consult.el
+++ b/consult.el
@@ -823,9 +823,8 @@ Otherwise the `default-directory' is returned."
           (cond
            ((stringp dir) dir)
            (dir
-            ;; HACK Preserve this-command across `read-directory-name' call,
+            ;; Preserve this-command across `read-directory-name' call,
             ;; such that `consult-customize' continues to work.
-            ;; TODO Find a better and more general solution which preserves 
`this-command'.
             (let ((this-command this-command))
               (read-directory-name "Directory: " nil nil t)))
            (t (or (consult--project-root) default-directory))))
@@ -852,9 +851,12 @@ When no project is found and MAY-PROMPT is non-nil ask the 
user."
 (defun consult--project-root (&optional may-prompt)
   "Return project root as absolute path.
 When no project is found and MAY-PROMPT is non-nil ask the user."
-  (when-let (root (and consult-project-function
-                       (funcall consult-project-function may-prompt)))
-    (expand-file-name root)))
+  ;; Preserve this-command across `read-directory-name' call,
+  ;; such that `consult-customize' continues to work.
+  (let ((this-command this-command))
+    (when-let (root (and consult-project-function
+                         (funcall consult-project-function may-prompt)))
+      (expand-file-name root))))
 
 (defun consult--project-name (dir)
   "Return the project name for DIR."

Reply via email to