Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,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
Expand Down
35 changes: 35 additions & 0 deletions embark.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2070,10 +2085,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
Expand Down
15 changes: 14 additions & 1 deletion embark.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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, after or around an action: Running hooks before after or around an action.
* Creating your own keymaps::
Expand Down Expand Up @@ -501,7 +502,7 @@ starting configuration:
;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly)

;; Add Embark to the mouse context menu. Also enable `context-menu-mode'.
;; (context-menu 1)
;; (context-menu-mode 1)
;; (add-hook 'context-menu-functions #'embark-context-menu 100)

:config
Expand Down Expand Up @@ -575,6 +576,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, after or around an action: Running hooks before after or around an action.
* Creating your own keymaps::
Expand Down Expand Up @@ -779,6 +781,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}.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be generated from the Org file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I see.

When I attempt to export the texinfo myself (via org-texinfo-export-to-texinfo), the resulting embark.texi differs in many places from what's in the repo. Is there some other way to do this? Or should I just update README.org in the PR, and leave it to @oantolin to export to texinfo?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually do it manually and just keep the relevant changes in the texinfo. But in my setup the difference is not that large.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated

@node Running some setup after injecting the target
@section Running some setup after injecting the target

Expand Down