summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.org4
-rw-r--r--README.org10
-rw-r--r--embark.el35
-rw-r--r--embark.texi13
4 files changed, 62 insertions, 0 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org
index dac0d45..45a9636 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -1,6 +1,10 @@
#+title: Embark changelog
* Development
+- Acted-on minibuffer candidates now get recorded in the minibuffer
+ history. You can configure which actions record history via the new
+ =embark-record-minibuffer-history= option; by default, we skip meta
+ commands such as =embark-export=, =embark-collect= and =embark-become=.
- =embark-target-buffer-at-point=: New target finder for buffers at point in
Ibuffer or Buffer-menu.
- =embark-context-menu=: Bew function which can be added to
diff --git a/README.org b/README.org
index 94f3444..6cc7097 100644
--- a/README.org
+++ b/README.org
@@ -616,6 +616,16 @@ non-quitting version as follows:
(embark-act)))
#+end_src
+** Recording acted-on minibuffer candidates in minibuffer history
+
+Confirming minibuffer input with =RET= records the selected candidate in
+the appropriate history list. The user option
+=embark-record-minibuffer-history= controls how Embark records acted-on
+candidates. This option accepts three kinds of values: =t= (always
+record), =nil= (never record), or =(skip ACTIONS...)= to record for
+everything except the listed actions. The default is a =skip= form that
+excludes meta commands such as =embark-export=.
+
** Running some setup after injecting the target
You can customize what happens after the target is inserted at the
diff --git a/embark.el b/embark.el
index 534ddba..b830c7d 100644
--- a/embark.el
+++ b/embark.el
@@ -314,6 +314,21 @@ some uses of `embark-act-all', namely, for those actions whose
entry in `embark-pre-action-hooks' includes `embark--confirm'."
:type 'boolean)
+(defcustom embark-record-minibuffer-history
+ '(skip embark-export embark-collect embark-live embark-become
+ embark-act-all embark-toggle-quit)
+ "Control when acted-on minibuffer candidates go into history.
+The value takes one of the following forms:
+
+ t Record for every action.
+ nil Never record.
+ (skip ACTIONS...) Record for every action not in ACTIONS."
+ :type '(choice (const :tag "Record for all actions" t)
+ (const :tag "Never record" nil)
+ (cons :tag "Record except for listed actions"
+ (const skip)
+ (repeat (function :tag "Action to skip")))))
+
(defcustom embark-default-action-overrides nil
"Alist associating target types with overriding default actions.
When the source of a target is minibuffer completion, the default
@@ -2068,10 +2083,30 @@ target as argument."
(command-execute (plist-get args :action)))))
:action action :quit quit target))
+(defun embark--record-history-p (action)
+ "Return non-nil if ACTION should push the current target to history."
+ (pcase embark-record-minibuffer-history
+ ('t t)
+ ('nil nil)
+ (`(skip . ,actions) (not (memq action actions)))
+ (_ nil)))
+
+(defun embark--record-target-in-history (action target)
+ "Record TARGET for ACTION in the current minibuffer history."
+ (when (and (minibufferp)
+ (embark--record-history-p action)
+ (not (eq minibuffer-history-variable t)))
+ (let ((raw (plist-get target :target)))
+ (when (stringp raw)
+ (add-to-history
+ minibuffer-history-variable
+ (substring-no-properties raw))))))
+
(defun embark--act (action target &optional quit)
"Perform ACTION injecting the TARGET.
If called from a minibuffer with non-nil QUIT, quit the
minibuffer before executing the action."
+ (embark--record-target-in-history action target)
(if (memq action '(embark-become ; these actions should run in
embark-collect ; the current buffer, not the
embark-live ; target buffer
diff --git a/embark.texi b/embark.texi
index 9c1f217..8fdde8d 100644
--- a/embark.texi
+++ b/embark.texi
@@ -55,6 +55,7 @@ Advanced configuration
* Showing information about available targets and actions::
* Selecting commands via completions instead of key bindings::
* Quitting the minibuffer after an action::
+* Recording acted-on minibuffer candidates in minibuffer history::
* Running some setup after injecting the target::
* Running hooks before@comma{} after or around an action::
* Creating your own keymaps::
@@ -573,6 +574,7 @@ integration despite this.)
* Showing information about available targets and actions::
* Selecting commands via completions instead of key bindings::
* Quitting the minibuffer after an action::
+* Recording acted-on minibuffer candidates in minibuffer history::
* Running some setup after injecting the target::
* Running hooks before@comma{} after or around an action::
* Creating your own keymaps::
@@ -777,6 +779,17 @@ non-quitting version as follows:
(embark-act)))
@end lisp
+@node Recording acted-on minibuffer candidates in minibuffer history
+@section Recording acted-on minibuffer candidates in minibuffer history
+
+Confirming minibuffer input with @samp{RET} records the selected candidate in
+the appropriate history list. The user option
+@samp{embark-record-minibuffer-history} controls how Embark records acted-on
+candidates. This option accepts three kinds of values: @samp{t} (always
+record), @samp{nil} (never record), or @samp{(skip ACTIONS...)} to record for
+everything except the listed actions. The default is a @samp{skip} form that
+excludes meta commands such as @samp{embark-export}.
+
@node Running some setup after injecting the target
@section Running some setup after injecting the target