Embark integration
NOTE: Install the ‘embark-consult’ package from MELPA, which provides Consult-specific Embark actions and the Occur buffer export.
Embark is a versatile package which offers context dependent actions, comparable to a context menu. See the Embark manual for an extensive description of its capabilities.
Actions are commands which can operate on the currently selected candidate (or target in Embark terminology). When completing files, for example the ‘delete-file’ command is offered. With Embark you can execute arbitrary commands on the currently selected candidate via ‘M-x’.
Furthermore Embark provides the ‘embark-collect’ command, which collects candidates and presents them in an Embark collect buffer, where further actions can be applied to them. A related feature is the ‘embark-export’ command, which exports candidate lists to a buffer of a special type. For example in the case of file completion, a Dired buffer is opened.
In the context of Consult, particularly exciting is the possibility to export the matching lines from ‘consult-line’, ‘consult-outline’, ‘consult-mark’ and ‘consult-global-mark’. The matching lines are exported to an Occur buffer where they can be edited via the ‘occur-edit-mode’ (press key ‘e’). Similarly, Embark supports exporting the matches found by ‘consult-grep’, ‘consult-ripgrep’ and ‘consult-git-grep’ to a Grep buffer, where the matches across files can be edited, via ‘grep-edit-mode’ on Emacs 31 (or via the wgrep package). These three workflows are symmetric.
- ‘
consult-line’ -> ‘embark-export’ to ‘occur-mode’ buffer -> ‘occur-edit-mode’ for editing of matches. - ‘
consult-grep’ -> ‘embark-export’ to ‘grep-mode’ buffer -> ‘grep-edit-mode’ for editing of matches. - ‘
consult-find’ -> ‘embark-export’ to ‘dired-mode’ buffer -> ‘wdired-change-to-wdired-mode’ for editing.