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

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

[elpa] externals/embark 0c6903cb0b: Run all actions with the default-dir


From: ELPA Syncer
Subject: [elpa] externals/embark 0c6903cb0b: Run all actions with the default-directory of the originating buffer
Date: Tue, 14 Mar 2023 14:58:01 -0400 (EDT)

branch: externals/embark
commit 0c6903cb0b51437a88bb32a82ab0c5ad6d626b85
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>

    Run all actions with the default-directory of the originating buffer
    
    There are two buffers relevant for embark-act: the buffer in which
    you run embark-act (here called the "originating buffer") and the
    target buffer, the buffer in which embark-act will run the action.
    
    These two buffers agree for actions from "regular" buffers, where
    "regular" means not the minibuffer and not an Embark Collect buffer.
    When you call embark-act in the minibuffer, the action is run in the
    buffer that was current when you ran the command that opened the
    minibuffer, and when you call embark-act from an Embark Collect
    buffer, the target buffer is the buffer that was current when you ran
    the command that produced the candidates in the first place.
    
    OK, enough background: with this change, when running an action in the
    target buffer, default-directory will be let-bound to the value of
    default-directory in the originating buffer. This fixes #612 and, I
    hope, doesn't mess anything else up.
---
 embark-consult.el | 13 ++-----------
 embark.el         |  4 +++-
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/embark-consult.el b/embark-consult.el
index 06832c10c7..a8d222b296 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -206,17 +206,8 @@ This function is meant to be added to 
`embark-collect-mode-hook'."
 
 (defun embark-consult-goto-grep (location)
   "Go to LOCATION, which should be a string with a grep match."
-  ;; Actions are run in the target window, so in this case whatever
-  ;; window was selected when the command that produced the
-  ;; xref-location candidates ran.  In particular, we inherit the
-  ;; default-directory of the buffer in that window, but we really
-  ;; want the default-directory of the minibuffer or collect window we
-  ;; call the action from, which is the previous window, since the
-  ;; location is given relative to that directory.
-  (let ((default-directory (with-selected-window (previous-window)
-                             default-directory)))
-    (consult--jump (consult--grep-position location))
-    (pulse-momentary-highlight-one-line (point))))
+  (consult--jump (consult--grep-position location))
+  (pulse-momentary-highlight-one-line (point)))
 
 (setf (alist-get 'consult-grep embark-default-action-overrides)
       #'embark-consult-goto-grep)
diff --git a/embark.el b/embark.el
index 6838b32f8f..2f08fd7863 100644
--- a/embark.el
+++ b/embark.el
@@ -1904,6 +1904,7 @@ minibuffer before executing the action."
     (let* ((command embark--command)
            (prefix prefix-arg)
            (action-window (embark--target-window t))
+           (directory default-directory)
            (inject
             (lambda ()
               (let ((contents (minibuffer-contents)))
@@ -1937,7 +1938,8 @@ minibuffer before executing the action."
                                 (prefix-arg prefix)
                                 ;; the next two avoid mouse dialogs
                                 (use-dialog-box nil)
-                                (last-nonmenu-event 13))
+                                (last-nonmenu-event 13)
+                                (default-directory directory))
                             (embark--run-action-hooks embark-pre-action-hooks
                                                       action target quit)
                             (minibuffer-with-setup-hook inject



reply via email to

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