[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark 6c44abb5d1 5/7: Allow multitarget actions to use
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark 6c44abb5d1 5/7: Allow multitarget actions to use around hooks |
Date: |
Wed, 6 Dec 2023 12:58:02 -0500 (EST) |
branch: externals/embark
commit 6c44abb5d17739c6c680c9d2891a78dcb6a671f1
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Allow multitarget actions to use around hooks
---
embark.el | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/embark.el b/embark.el
index f9aa342733..6884509b8e 100644
--- a/embark.el
+++ b/embark.el
@@ -1981,7 +1981,8 @@ arguments are passed to the hooks as keyword arguments."
(mapc (lambda (h) (apply h :action action :quit quit target))
(alist-get :always hooks)))
-(defun embark--run-around-action-hooks (action target quit)
+(defun embark--run-around-action-hooks
+ (action target quit &optional non-interactive)
"Run the `embark-around-action-hooks' for ACTION.
All the applicable around hooks are composed in the order they
are present in `embark-around-action-hooks'. The keys t and
@@ -1989,7 +1990,11 @@ are present in `embark-around-action-hooks'. The keys t
and
The :always hooks are executed always (outermost) and the t hooks
are the default hooks, for when there are no command-specific
hooks for ACTION. The QUIT, ACTION and TARGET arguments are
-passed to the hooks as keyword arguments."
+passed to the hooks as keyword arguments.
+
+The optional argument NON-INTERACTIVE controls whether the action
+is run with `command-execute' or with `funcall' passing the
+target as argument."
(apply
(seq-reduce
(lambda (fn hook)
@@ -1998,8 +2003,12 @@ passed to the hooks as keyword arguments."
(reverse
(append (or (alist-get action hooks) (alist-get t hooks))
(alist-get :always hooks))))
- (lambda (&rest args)
- (command-execute (plist-get args :action))))
+ (if non-interactive
+ (lambda (&rest args)
+ (funcall (plist-get args :action)
+ (or (plist-get args :candidates) (plist-get args :target))))
+ (lambda (&rest args)
+ (command-execute (plist-get args :action)))))
:action action :quit quit target))
(defun embark--act (action target &optional quit)
@@ -2074,12 +2083,11 @@ minibuffer before executing the action."
(when dedicate (set-window-dedicated-p dedicate nil)))
(unless (eq final-window action-window)
(select-window final-window))))
- ;; TODO uniformize the command and non-interactive cases?
- (let ((argument
- (if multi
- (or (plist-get target :candidates) ; embark-act-all
- (list (plist-get target :target)))
- (plist-get target :target))))
+ (let ((target
+ (if (and multi (null (plist-get target :candidates)))
+ (plist-put
+ target :candidates (list (plist-get target :target)))
+ target)))
(lambda ()
(with-selected-window action-window
(embark--run-action-hooks embark-pre-action-hooks
@@ -2088,7 +2096,7 @@ minibuffer before executing the action."
(let ((current-prefix-arg prefix)
(default-directory directory))
(embark--run-around-action-hooks
- action target quit))
+ action target quit :non-interactive))
(embark--run-action-hooks embark-post-action-hooks
action target quit))))))))
(setq prefix-arg nil)
- [elpa] externals/embark updated (b24295ea88 -> 95517246d8), ELPA Syncer, 2023/12/06
- [elpa] externals/embark bb4757acf4 1/7: Add alist of filepath extraction functions for various types, ELPA Syncer, 2023/12/06
- [elpa] externals/embark d2294221ac 2/7: Also run around action hounds for multitarget actions, ELPA Syncer, 2023/12/06
- [elpa] externals/embark c40d538709 3/7: DWIM behavior for consult async search commands, ELPA Syncer, 2023/12/06
- [elpa] externals/embark a05b77f490 6/7: Document new consult async dwim behavior, ELPA Syncer, 2023/12/06
- [elpa] externals/embark 95517246d8 7/7: Merge branch 'consult-grep-dwim', ELPA Syncer, 2023/12/06
- [elpa] externals/embark a1df6a93c0 4/7: if a buffer is visiting a file, that's the associated file, ELPA Syncer, 2023/12/06
- [elpa] externals/embark 6c44abb5d1 5/7: Allow multitarget actions to use around hooks,
ELPA Syncer <=