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

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

[elpa] externals/embark 37bf538667 1/2: Make embark-select callable as a


From: ELPA Syncer
Subject: [elpa] externals/embark 37bf538667 1/2: Make embark-select callable as a top-level command (fix #648)
Date: Tue, 11 Jul 2023 15:57:46 -0400 (EDT)

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

    Make embark-select callable as a top-level command (fix #648)
---
 CHANGELOG.org |  3 +++
 README.org    | 27 +++++++++++++++------------
 embark.el     | 18 ++++++++++++------
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 9bb78fdd0f..d8c35e561a 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -3,6 +3,9 @@
 * Development version
 - Added a mode line indicator showing the number of selected targets in
   the current buffer (contributed by @minad, thanks!)
+- Now =embark-select= can also be called as a top-level command, from
+  outside =embark-act=. When called that way, it will select the first
+  target at point.
 - Renamed =embark-isearch= to =embark-isearch-forward= and added
   =embark-isearch-backward=.
 - Added key bindings for org agenda items consistent with those of org
diff --git a/README.org b/README.org
index 8d4d641fec..27e77a561e 100644
--- a/README.org
+++ b/README.org
@@ -176,10 +176,11 @@ sets:
   The candidates are displayed as a list showing additional annotations.
 
   The Embark Collect buffer is somewhat "dired-like": you can select
-  and deselect candidates through the =embark-select= action (bound to
-  =SPC=). In an Embark Collect buffer =embark-act= is bound to =a= and
-  =embark-act-all= is bound to =A=; =embark-act-all= will act on all
-  currently marked candidates if there any, and will act on all
+  and deselect candidates through =embark-select= (available as an
+  action in =embark-act=, bound to =SPC=; but you could also give it a
+  global key binding). In an Embark Collect buffer =embark-act= is bound
+  to =a= and =embark-act-all= is bound to =A=; =embark-act-all= will act on
+  all currently marked candidates if there any, and will act on all
   candidates if none are marked. In particular, this means that =a SPC=
   will toggle whether the candidate at point is selected, and =A SPC=
   will select all candidates if none are selected, or deselect all
@@ -230,14 +231,16 @@ or in a dired buffer they work on all marked files (or 
all files if
 none are marked). Embark also has a notion of /selection/, where you can
 accumulate an ad hoc list of targets for these commands to work on.
 
-The selection is controlled by using the =embark-select= action (which
-must be run as an action through =embark-act=), bound to =SPC= in
-=embark-general-map= so that it is always available. Calling this action
-on a target toggles its membership in the current buffer's Embark
-selection; that is, it adds it to selection if not selected and
-removes it from the selection if it was selected. Whenever the
-selection for a buffer is non-empty, the commands =embark-act-all=,
-=embark-export= and =embark-collect= will act on the selection.
+The selection is controlled by using the =embark-select= action, bound
+to =SPC= in =embark-general-map= so that it is always available (you can
+also give =embark-select= a global key binding if you wish; when called
+directly, not as an action for =embark-act=, it will select the first
+target at point). Calling this action on a target toggles its
+membership in the current buffer's Embark selection; that is, it adds
+it to selection if not selected and removes it from the selection if
+it was selected. Whenever the selection for a buffer is non-empty, the
+commands =embark-act-all=, =embark-export= and =embark-collect= will act on
+the selection.
 
 To deselect all selected targets, you can use the =embark-select= action
 through =embark-act-all=, since this will run =embark-select= on each
diff --git a/embark.el b/embark.el
index cf08fec1fb..42ccdf72be 100644
--- a/embark.el
+++ b/embark.el
@@ -416,9 +416,7 @@ the key :always are executed always."
     (mark embark--mark-target)
     ;; shells in new buffers
     (shell embark--universal-argument)
-    (eshell embark--universal-argument)
-    ;; do the actual work of selecting & deselecting targets
-    (embark-select embark--select))
+    (eshell embark--universal-argument))
   "Alist associating commands with pre-action hooks.
 The hooks are run right before an action is embarked upon.  See
 `embark-target-injection-hooks' for information about the hook
@@ -480,7 +478,9 @@ arguments and more details."
     (append-to-file embark--mark-target)
     (shell-command-on-region embark--mark-target)
     (embark-eval-replace embark--mark-target)
-    (delete-indentation embark--mark-target))
+    (delete-indentation embark--mark-target)
+    ;; do the actual work of selecting & deselecting targets
+    (embark-select embark--select))
   "Alist associating commands with post-action hooks.
 The hooks are run instead of the embarked upon action.  The hook
 can decide whether or not to run the action or it can run it
@@ -3372,9 +3372,15 @@ If BOUNDS are given, also highlight the target when 
selecting it."
     (add-to-list 'mode-line-misc-info '(:eval (embark--selection-indicator)))
     (force-mode-line-update t)))
 
-(defalias 'embark-select #'ignore
+(defun embark-select ()
   "Add or remove the target from the current buffer's selection.
-You can act on all selected targets at once with `embark-act-all'.")
+You can act on all selected targets at once with `embark-act-all'.
+When called from outside `embark-act' this command will select
+the first target at point."
+  (interactive)
+  (if-let ((target (car (embark--targets))))
+      (apply #'embark--select target)
+    (user-error "No target to select")))
 
 (defun embark-selected-candidates ()
   "Return currently selected candidates in the buffer."



reply via email to

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