README.org (58131B)
1 #+TITLE: Embark: Emacs Mini-Buffer Actions Rooted in Keymaps 2 #+OPTIONS: d:nil 3 #+EXPORT_FILE_NAME: embark.texi 4 #+TEXINFO_DIR_CATEGORY: Emacs misc features 5 #+TEXINFO_DIR_TITLE: Embark: (embark). 6 #+TEXINFO_DIR_DESC: Emacs Mini-Buffer Actions Rooted in Keymaps 7 8 #+html: <a href="http://elpa.gnu.org/packages/embark.html"><img alt="GNU ELPA" src="https://elpa.gnu.org/packages/embark.svg"/></a> 9 #+html: <a href="http://elpa.gnu.org/devel/embark.html"><img alt="GNU-devel ELPA" src="https://elpa.gnu.org/devel/embark.svg"/></a> 10 #+html: <a href="https://melpa.org/#/embark"><img alt="MELPA" src="https://melpa.org/packages/embark-badge.svg"/></a> 11 #+html: <a href="https://stable.melpa.org/#/embark"><img alt="MELPA Stable" src="https://stable.melpa.org/packages/embark-badge.svg"/></a> 12 13 * Overview 14 15 Embark makes it easy to choose a command to run based on what is near 16 point, both during a minibuffer completion session (in a way familiar 17 to Helm or Counsel users) and in normal buffers. Bind the command 18 =embark-act= to a key and it acts like prefix-key for a keymap of 19 /actions/ (commands) relevant to the /target/ around point. With point on 20 an URL in a buffer you can open the URL in a browser or eww or 21 download the file it points to. If while switching buffers you spot an 22 old one, you can kill it right there and continue to select another. 23 Embark comes preconfigured with over a hundred actions for common 24 types of targets such as files, buffers, identifiers, s-expressions, 25 sentences; and it is easy to add more actions and more target types. 26 Embark can also collect all the candidates in a minibuffer to an 27 occur-like buffer or export them to a buffer in a major-mode specific 28 to the type of candidates, such as dired for a set of files, ibuffer 29 for a set of buffers, or customize for a set of variables. 30 31 ** Acting on targets 32 33 You can think of =embark-act= as a keyboard-based version of a 34 right-click contextual menu. The =embark-act= command (which you should 35 bind to a convenient key), acts as a prefix for a keymap offering you 36 relevant /actions/ to use on a /target/ determined by the context: 37 38 - In the minibuffer, the target is the current top completion 39 candidate. 40 - In the =*Completions*= buffer the target is the completion at point. 41 - In a regular buffer, the target is the region if active, or else the 42 file, symbol, URL, s-expression or defun at point. 43 44 Multiple targets can be present at the same location and you can cycle 45 between them by repeating the =embark-act= key binding. The type of 46 actions offered depend on the type of the target. Here is a sample of 47 a few of the actions offered in the default configuration: 48 49 - For files you get offered actions like deleting, copying, 50 renaming, visiting in another window, running a shell command on the 51 file, etc. 52 - For buffers the actions include switching to or killing the buffer. 53 - For package names the actions include installing, removing or 54 visiting the homepage. 55 - For Emacs Lisp symbols the actions include finding the definition, 56 looking up documentation, evaluating (which for a variable 57 immediately shows the value, but for a function lets you pass it 58 some arguments first). There are some actions specific to variables, 59 such as setting the value directly or though the customize system, 60 and some actions specific to commands, such as binding it to a key. 61 62 By default when you use =embark-act= if you don't immediately select an 63 action, after a short delay Embark will pop up a buffer showing a list 64 of actions and their corresponding key bindings. If you are using 65 =embark-act= outside the minibuffer, Embark will also highlight the 66 current target. These behaviors are configurable via the variable 67 =embark-indicators=. Instead of selecting an action via its key binding, 68 you can select it by name with completion by typing =C-h= after 69 =embark-act=. 70 71 Everything is easily configurable: determining the current target, 72 classifying it, and deciding which actions are offered for each type 73 in the classification. The above introduction just mentions part of 74 the default configuration. 75 76 Configuring which actions are offered for a type is particularly easy 77 and requires no programming: the variable =embark-keymap-alist= 78 associates target types with variables containing keymaps, and those 79 keymaps containing bindings for the actions. (To examine the available 80 categories and their associated keymaps, you can use =C-h v 81 embark-keymap-alist= or customize that variable.) For example, in the 82 default configuration the type =file= is associated with the symbol 83 =embark-file-map=. That symbol names a keymap with single-letter key 84 bindings for common Emacs file commands, for instance =c= is bound to 85 =copy-file=. This means that if you are in the minibuffer after running 86 a command that prompts for a file, such as =find-file= or =rename-file=, 87 you can copy a file by running =embark-act= and then pressing =c=. 88 89 These action keymaps are very convenient but not strictly necessary 90 when using =embark-act=: you can use any command that reads from the 91 minibuffer as an action and the target of the action will be inserted 92 at the first minibuffer prompt. After running =embark-act= all of your 93 key bindings and even =execute-extended-command= can be used to run a 94 command. For example, if you want to replace all occurrences of the 95 symbol at point, just use =M-%= as the action, there is no need to bind 96 =query-replace= in one of Embark's keymaps. Also, those action keymaps 97 are normal Emacs keymaps and you should feel free to bind in them 98 whatever commands you find useful as actions and want to be available 99 through convenient bindings. 100 101 The actions in =embark-general-map= are available no matter what type 102 of completion you are in the middle of. By default this includes 103 bindings to save the current candidate in the kill ring and to insert 104 the current candidate in the previously selected buffer (the buffer 105 that was current when you executed a command that opened up the 106 minibuffer). 107 108 Emacs's minibuffer completion system includes metadata indicating the 109 /category/ of what is being completed. For example, =find-file='s 110 metadata indicates a category of =file= and =switch-to-buffer='s metadata 111 indicates a category of =buffer=. Embark has the related notion of the 112 /type/ of a target for actions, and by default when category metadata 113 is present it is taken to be the type of minibuffer completion 114 candidates when used as targets. Emacs commands often do not set 115 useful category metadata so the [[https://github.com/minad/marginalia][Marginalia]] package, which supplies 116 this missing metadata, is highly recommended for use with Embark. 117 118 Embark's default configuration has actions for the following target 119 types: files, buffers, symbols, packages, URLs, bookmarks, and as a 120 somewhat special case, actions for when the region is active. You can 121 read about the [[https://github.com/oantolin/embark/wiki/Default-Actions][default actions and their key bindings]] on the GitHub 122 project wiki. 123 124 ** The default action on a target 125 126 Embark has a notion of default action for a target: 127 128 - If the target is a minibuffer completion candidate, then the default 129 action is whatever command opened the minibuffer in the first place. 130 For example if you run =kill-buffer=, then the default action will be 131 to kill buffers. 132 - If the target comes from a regular buffer (i.e., not a minibuffer), 133 then the default action is whatever is bound to =RET= in the keymap of 134 actions for that type of target. For example, in Embark's default 135 configuration for a URL found at point the default action is 136 =browse-url=, because =RET= is bound to =browse-url= in the =embark-url-map= 137 keymap. 138 139 To run the default action you can press =RET= after running =embark-act=. 140 Note that if there are several different targets at a given location, 141 each has its own default action, so first cycle to the target you want 142 and then press =RET= to run the corresponding default action. 143 144 There is also =embark-dwim= which runs the default action for the first 145 target found. It's pretty handy in non-minibuffer buffers: with 146 Embark's default configuration it will: 147 148 - Open the file at point. 149 - Open the URL at point in a web browser (using the =browse-url= 150 command). 151 - Compose a new email to the email address at point. 152 - In an Emacs Lisp buffer, if point is on an opening parenthesis or 153 right after a closing one, it will evaluate the corresponding 154 expression. 155 - Go to the definition of an Emacs Lisp function, variable or macro at 156 point. 157 - Find the file corresponding to an Emacs Lisp library at point. 158 159 ** Working with sets of possible targets 160 161 Besides acting individually on targets, Embark lets you work 162 collectively on a set of target /candidates/. For example, while you are 163 in the minibuffer the candidates are simply the possible completions 164 of your input. Embark provides three main commands to work on candidate 165 sets: 166 167 - The =embark-act-all= command runs the same action on each of the 168 current candidates. It is just like using =embark-act= on each 169 candidate in turn. (Because you can easily act on many more 170 candidates than you meant to, by default Embark asks you to confirm 171 uses of =embark-act-all=; you can turn this off by setting the user 172 option =embark-confirm-act-all= to =nil=.) 173 174 - The =embark-collect= command produces a buffer listing all the current 175 candidates, for you to peruse and run actions on at your leisure. 176 The candidates are displayed as a list showing additional annotations. 177 178 The Embark Collect buffer is somewhat "dired-like": you can select 179 and deselect candidates through the =embark-select= action (bound to 180 =SPC=). In an Embark Collect buffer =embark-act= is bound to =a= and 181 =embark-act-all= is bound to =A=; =embark-act-all= will act on all 182 currently marked candidates if there any, and will act on all 183 candidates if none are marked. In particular, this means that =a SPC= 184 will toggle whether the candidate at point is selected, and =A SPC= 185 will select all candidates if none are selected, or deselect all 186 selected candidates if there are some. 187 188 - The =embark-export= command tries to open a buffer in an appropriate 189 major mode for the set of candidates. If the candidates are files 190 export produces a Dired buffer; if they are buffers, you get an 191 Ibuffer buffer; and if they are packages you get a buffer in 192 package menu mode. 193 194 If you use the grepping commands from the [[https://github.com/minad/consult/][Consult]] package, 195 =consult-grep=, =consult-git-grep= or =consult-ripgrep=, then you should 196 install the =embark-consult= package, which adds support for exporting a 197 list of grep results to an honest grep-mode buffer, on which you can 198 even use [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep]] if you wish. 199 200 When in doubt choosing between exporting and collecting, a good rule 201 of thumb is to always prefer =embark-export= since when an exporter to a 202 special major mode is available for a given type of target, it will be 203 more featureful than an Embark collect buffer, and if no such exporter 204 is configured the =embark-export= command falls back to the generic 205 =embark-collect=. 206 207 These commands are always available as "actions" (although they do not 208 act on just the current target but on all candidates) for =embark-act= 209 and are bound to =A=, =S= (for "snapshot"), and =E=, respectively, in 210 =embark-general-map=. This means that you do not have to bind your own 211 key bindings for these (although you can, of course!), just a key 212 binding for =embark-act=. 213 214 In Embark Collect or Embark Export buffers that were obtained by 215 running =embark-collect= or =embark-export= from within a minibuffer 216 completion session, =g= is bound to a command that restarts the 217 completion session, that is, the command that opened the minibuffer is 218 run again and the minibuffer contents restored. You can then interact 219 normally with the command, perhaps editing the minibuffer contents, 220 and, if you wish, you can rerun =embark-collect= or =embark-export= to get 221 an updated buffer. 222 223 *** Selecting some targets to make an ad hoc candidate set 224 225 The commands for working with sets of candidates just described, 226 namely =embark-act-all=, =embark-export= and =embark-collect= by default 227 work with all candidates defined in the current context. For example, 228 in the minibuffer they operate on all currently completion candidates, 229 or in a dired buffer they work on all marked files (or all files if 230 none are marked). Embark also has a notion of /selection/, where you can 231 accumulate an ad hoc list of targets for these commands to work on. 232 233 The selection is controlled by using the =embark-select= action (which 234 must be run as an action through =embark-act=), bound to =SPC= in 235 =embark-general-map= so that it is always available. Calling this action 236 on a target toggles its membership in the current buffer's Embark 237 selection; that is, it adds it to selection if not selected and 238 removes it from the selection if it was selected. Whenever the 239 selection for a buffer is non-empty, the commands =embark-act-all=, 240 =embark-export= and =embark-collect= will act on the selection. 241 242 To deselect all selected targets, you can use the =embark-select= action 243 through =embark-act-all=, since this will run =embark-select= on each 244 member of the current selection. Similarly if no targets are selected 245 and you are in a minibuffer completion session, running =embark-select= 246 from =embark-act-all= will select all the current completion candidates. 247 248 This functionality is supported everywhere: 249 250 - In the minibuffer this gives a convenient way to act on several 251 completion candidates that don't follow any simple pattern: just go 252 through the completions selecting the ones you want, then use 253 =embark-act-all=. For example, you could attach several files at once 254 to an email. 255 - For Embark Collect buffers this functionality enables a dired-like 256 workflow, in which you mark various candidates and apply an action 257 to all at once. (It supersedes a previous ad hoc dired-like 258 interface that was implemented only in Embark Collect buffers, with 259 a slightly different interface.) 260 - In a eww buffer you could use this to select various links you wish 261 to follow up on, and then collect them into a buffer. Similarly, 262 while reading Emacs's info manual you could select some symbols you 263 want to read more about and export them to an =apropos-mode= buffer. 264 - You can use selections in regular text or programming buffers to do 265 complex editing operations. For example, if you have three 266 paragraphs scattered over a file and you want to bring them 267 together, you can select each one, insert them all somewhere and 268 finally delete all of them (from their original locations). 269 270 271 *** =embark-live= a live-updating variant of =embark-collect= 272 273 Finally, there is also an =embark-live= variant of the =embark-collect= 274 command which automatically updates the collection after each change 275 in the source buffer. Users of a completion UI that automatically 276 updates and displays the candidate list (such as Vertico, Icomplete, 277 Fido-mode, or MCT) will probably not want to use 278 =embark-live= from the minibuffer as they will then have two live 279 updating displays of the completion candidates! 280 281 A more likely use of =embark-live= is to be called from a regular buffer 282 to display a sort of live updating "table of contents" for the buffer. 283 This depends on having appropriate candidate collectors configured in 284 =embark-candidate-collectors=. There are not many in Embark's default 285 configuration, but you can try this experiment: open a dired buffer in 286 a directory that has very many files, mark a few, and run =embark-live=. 287 You'll get an Embark Collect buffer containing only the marked files, 288 which updates as you mark or unmark files in dired. To make 289 =embark-live= genuinely useful other candidate collectors are required. 290 The =embark-consult= package (documented near the end of this manual) 291 contains a few: one for imenu items and one for outline headings as 292 used by =outline-minor-mode=. Those collectors really do give 293 =embark-live= a table-of-contents feel. 294 295 ** Switching to a different command without losing what you've typed 296 297 Embark also has the =embark-become= command which is useful for when 298 you run a command, start typing at the minibuffer and realize you 299 meant a different command. The most common case for me is that I run 300 =switch-to-buffer=, start typing a buffer name and realize I haven't 301 opened the file I had in mind yet! I'll use this situation as a 302 running example to illustrate =embark-become=. When this happens I can, 303 of course, press =C-g= and then run =find-file= and open the file, but 304 this requires retyping the portion of the file name you already 305 typed. This process can be streamlined with =embark-become=: while still 306 in the =switch-to-buffer= you can run =embark-become= and effectively 307 make the =switch-to-buffer= command become =find-file= for this run. 308 309 You can bind =embark-become= to a key in =minibuffer-local-map=, but it is 310 also available as an action under the letter =B= (uppercase), so you 311 don't need a binding if you already have one for =embark-act=. So, 312 assuming I have =embark-act= bound to, say, =C-.=, once I realize I 313 haven't open the file I can type =C-. B C-x C-f= to have 314 =switch-to-buffer= become =find-file= without losing what I have already 315 typed in the minibuffer. 316 317 But for even more convenience, =embark-become= offers shorter key 318 bindings for commands you are likely to want the current command to 319 become. When you use =embark-become= it looks for the current command in 320 all keymaps named in the list =embark-become-keymaps= and then activates 321 all keymaps that contain it. For example, the default value of 322 =embark-become-keymaps= contains a keymap =embark-become-file+buffer-map= 323 with bindings for several commands related to files and buffers, in 324 particular, it binds =switch-to-buffer= to =b= and =find-file= to =f=. So when 325 I accidentally try to switch to a buffer for a file I haven't opened 326 yet, =embark-become= finds that the command I ran, =switch-to-buffer=, is 327 in the keymap =embark-become-file+buffer-map=, so it activates that 328 keymap (and any others that also contain a binding for 329 =switch-to-buffer=). The end result is that I can type =C-. B f= to 330 switch to =find-file=. 331 332 * Quick start 333 334 The easiest way to install Embark is from GNU ELPA, just run =M-x 335 package-install RET embark RET=. (It is also available on MELPA.) It is 336 highly recommended to also install [[https://github.com/minad/marginalia][Marginalia]] (also available on GNU 337 ELPA), so that Embark can offer you preconfigured actions in more 338 contexts. For =use-package= users, the following is a very reasonable 339 starting configuration: 340 341 #+begin_src emacs-lisp 342 (use-package marginalia 343 :ensure t 344 :config 345 (marginalia-mode)) 346 347 (use-package embark 348 :ensure t 349 350 :bind 351 (("C-." . embark-act) ;; pick some comfortable binding 352 ("C-;" . embark-dwim) ;; good alternative: M-. 353 ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings' 354 355 :init 356 357 ;; Optionally replace the key help with a completing-read interface 358 (setq prefix-help-command #'embark-prefix-help-command) 359 360 ;; Show the Embark target at point via Eldoc. You may adjust the Eldoc 361 ;; strategy, if you want to see the documentation from multiple providers. 362 (add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target) 363 ;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly) 364 365 :config 366 367 ;; Hide the mode line of the Embark live/completions buffers 368 (add-to-list 'display-buffer-alist 369 '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" 370 nil 371 (window-parameters (mode-line-format . none))))) 372 373 ;; Consult users will also want the embark-consult package. 374 (use-package embark-consult 375 :ensure t ; only need to install it, embark loads it after consult if found 376 :hook 377 (embark-collect-mode . consult-preview-at-point-mode)) 378 #+end_src 379 380 About the suggested key bindings for =embark-act= and =embark-dwim=: 381 - Those key bindings are unlikely to work in the terminal, but 382 terminal users are probably well aware of this and will know to 383 select different bindings. 384 - The suggested =C-.= binding is used by default in (at least some 385 installations of) GNOME to input emojis, and Emacs doesn't even get 386 a chance to respond to the binding. You can select a different key 387 binding for =embark-act= or use =ibus-setup= to change the shortcut for 388 emoji insertion (Emacs 29 will likely use =C-x 8 e e=, in case you 389 want to set the same one system-wide). 390 - The suggested alternative of =M-.= for =embark-dwim= is bound by default 391 to =xref-find-definitions=. That is a very useful command but 392 overwriting it with =embark-dwim= is sensible since in Embark's 393 default configuration, =embark-dwim= will also find the definition of 394 the identifier at point. (Note that =xref-find-definitions= with a 395 prefix argument prompts you for an identifier, =embark-dwim= does not 396 cover this case). 397 398 Other Embark commands such as =embark-act-all=, =embark-become=, 399 =embark-collect=, and =embark-export= can be run through =embark-act= as 400 actions bound to =A=, =B=, =S= (for "snapshot"), and =E= respectively, and 401 thus don't really need a dedicated key binding, but feel free to bind 402 them directly if you so wish. If you do choose to bind them directly, 403 you'll probably want to bind them in =minibuffer-local-map=, since they 404 are most useful in the minibuffer (in fact, =embark-become= only works 405 in the minibuffer). 406 407 The command =embark-dwim= executes the default action at point. Another good 408 keybinding for =embark-dwim= is =M-.= since =embark-dwim= acts like 409 =xref-find-definitions= on the symbol at point. =C-.= can be seen as a 410 right-click context menu at point and =M-.= acts like left-click. The 411 keybindings are mnemonic, both act at the point (=.=). 412 413 Embark needs to know what your minibuffer completion system considers 414 to be the list of candidates and which one is the current candidate. 415 Embark works out of the box if you use Emacs's default tab completion, 416 the built-in =icomplete-mode= or =fido-mode=, or the third-party packages 417 [[https://github.com/minad/vertico][Vertico]] or [[https://github.com/abo-abo/swiper][Ivy]]. 418 419 If you are a [[https://emacs-helm.github.io/helm/][Helm]] or [[https://github.com/abo-abo/swiper][Ivy]] user you are unlikely to want Embark since 420 those packages include comprehensive functionality for acting on 421 minibuffer completion candidates. (Embark does come with Ivy 422 integration despite this.) 423 424 * Advanced configuration 425 ** Showing information about available targets and actions 426 427 By default, if you run =embark-act= and do not immediately select an 428 action, after a short delay Embark will pop up a buffer called =*Embark 429 Actions*= containing a list of available actions with their key 430 bindings. You can scroll that buffer with the mouse of with the usual 431 commands =scroll-other-window= and =scroll-other-window-down= (bound by 432 default to =C-M-v= and =C-M-S-v=). 433 434 That functionality is provided by the =embark-mixed-indicator=, but 435 Embark has other indicators that can provide information about the 436 target and its type, what other targets you can cycle to, and which 437 actions have key bindings in the action map for the current type of 438 target. Any number of indicators can be active at once and the user 439 option =embark-indicators= should be set to a list of the desired 440 indicators. 441 442 Embark comes with the following indicators: 443 444 - =embark-minimal-indicator=: shows a messages in the echo area or 445 minibuffer prompt showing the current target and the types of all 446 targets starting with the current one; this one is on by default. 447 448 - =embark-highlight-indicator=: highlights the target at point; 449 also on by default. 450 451 - =embark-verbose-indicator=: displays a table of actions and their key 452 bindings in a buffer; this is not on by default, in favor of the 453 mixed indicator described next. 454 455 - =embark-mixed-indicator=: starts out by behaving as the minimal 456 indicator but after a short delay acts as the verbose indicator; 457 this is on by default. 458 459 - =embark-isearch-highlight-indicator=: this only does something when 460 the current target is the symbol at point, in which case it 461 lazily highlights all occurrences of that symbol in the current 462 buffer, like isearch; also on by default. 463 464 Users of the popular [[https://github.com/justbur/emacs-which-key][which-key]] package may prefer to use the 465 =embark-which-key-indicator= from the [[https://github.com/oantolin/embark/wiki/Additional-Configuration#use-which-key-like-a-key-menu-prompt][Embark wiki]]. Just copy its 466 definition from the wiki into your configuration and customize the 467 =embark-indicators= user option to exclude the mixed and verbose 468 indicators and to include =embark-which-key-indicator=. 469 470 ** Selecting commands via completions instead of key bindings 471 472 As an alternative to reading the list of actions in the verbose or 473 mixed indicators (see the previous section for a description of 474 these), you can press the =embark-help-key=, which is =C-h= by default 475 (but you may prefer =?= to free up =C-h= for use as a prefix) after 476 running =embark-act=. Pressing the help key will prompt you for the name 477 of an action with completion (but feel free to enter a command that is 478 not among the offered candidates!), and will also remind you of the 479 key bindings. You can press =embark-keymap-prompter-key=, which is =@= by 480 default, at the prompt and then one of the key bindings to enter the 481 name of the corresponding action. 482 483 You may think that with the =*Embark Actions*= buffer popping up to 484 remind you of the key bindings you'd never want to use completion to 485 select an action by name, but personally I find that typing a small 486 portion of the action name to narrow down the list of candidates feels 487 significantly faster than visually scanning the entire list of actions. 488 489 If you find you prefer entering actions that way, you can configure 490 embark to always prompt you for actions by setting the variable 491 =embark-prompter= to =embark-completing-read-prompter=. 492 493 ** Quitting the minibuffer after an action 494 495 By default, if you call =embark-act= from the minibuffer it quits the 496 minibuffer after performing the action. You can change this by setting 497 the user option =embark-quit-after-action= to =nil=. Having =embark-act= /not/ 498 quit the minibuffer can be useful to turn commands into little "thing 499 managers". For example, you can use =find-file= as a little file manager 500 or =describe-package= as a little package manager: you can run those 501 commands, perform a series of actions, and then quit the command. 502 503 If you want to control the quitting behavior in a fine-grained manner 504 depending on the action, you can set =embark-quit-after-action= to an 505 alist, associating commands to either =t= for quitting or =nil= for not 506 quitting. When using an alist, you can use the special key =t= to 507 specify the default behavior. For example, to specify that by default 508 actions should not quit the minibuffer but that using =kill-buffer= as 509 an action should quit, you can use the following configuration: 510 511 #+begin_src emacs-lisp 512 (setq embark-quit-after-action '((kill-buffer . t) (t . nil))) 513 #+end_src 514 515 The variable =embark-quit-after-action= only specifies a default, that 516 is, it only controls whether or not =embark-act= quits the minibuffer 517 when you call it without a prefix argument, and you can select the 518 opposite behavior to what the variable says by calling =embark-act= with 519 =C-u=. Also note that both the variable =embark-quit-after-action= and =C-u= 520 have no effect when you call =embark-act= outside the minibuffer. 521 522 If you find yourself using the quitting and non-quitting variants of 523 =embark-act= about equally often, independently of the action, you may 524 prefer to simply have separate commands for them instead of a single 525 command that you call with =C-u= half the time. You could, for example, 526 keep the default exiting behavior of =embark-act= and define a 527 non-quitting version as follows: 528 529 #+begin_src emacs-lisp 530 (defun embark-act-noquit () 531 "Run action but don't quit the minibuffer afterwards." 532 (interactive) 533 (let ((embark-quit-after-action nil)) 534 (embark-act))) 535 #+end_src 536 537 ** Running some setup after injecting the target 538 539 You can customize what happens after the target is inserted at the 540 minibuffer prompt of an action. There are 541 =embark-target-injection-hooks=, that are run by default after injecting 542 the target into the minibuffer. The variable 543 =embark-target-injection-hooks= is an alist associating commands to 544 their setup hooks. There are two special keys: if no setup hook is 545 specified for a given action, the hook associated to =t= is run; and the 546 hook associated to =:always= is run regardless of the action. (This 547 variable used to have the less explicit name of 548 =embark-setup-action-hooks=, so please update your configuration.) 549 550 For example, consider using =shell-command= as an action during file 551 completion. It would be useful to insert a space before the target 552 file name and to leave the point at the beginning, so you can 553 immediately type the shell command to run on that file. That's why in 554 Embark's default configuration there is an entry in 555 =embark-target-injection-hooks= associating =shell-command= to a hook that 556 includes =embark--shell-prep=, a simple helper function that quotes all 557 the spaces in the file name, inserts an extra space at the beginning 558 of the line and leaves point to the left of it. 559 560 Now, the preparation that =embark--shell-prep= does would be useless if 561 Embark did what it normally does after it inserts the target of the 562 action at the minibuffer prompt, which is to "press =RET=" for you, 563 accepting the target as is; if Embark did that for =shell-command= you 564 wouldn't get a chance to type in the command to execute! That is why 565 in Embark's default configuration the entry for =shell-command= in 566 =embark-target-injection-hooks= also contains the function 567 =embark--allow-edit=. 568 569 Embark used to have a dedicated variable =embark-allow-edit-actions= to 570 which you could add commands for which Embark should forgo pressing 571 =RET= for you after inserting the target. Since its effect can also be 572 achieved via the general =embark-target-injection-hooks= mechanism, that 573 variable has been removed to simply Embark. Be sure to update your 574 configuration; if you had something like: 575 576 #+begin_src emacs-lisp 577 (add-to-list 'embark-allow-edit-actions 'my-command) 578 #+end_src 579 580 you should replace it with: 581 582 #+begin_src emacs-lisp 583 (push 'embark--allow-edit 584 (alist-get 'my-command embark-target-injection-hooks)) 585 #+end_src 586 587 588 Also note that while you could abuse =embark--allow-edit= so that you 589 have to confirm "dangerous" actions such as =delete-file=, it is better 590 to implement confirmation by adding the =embark--confirm= function to 591 the appropriate entry of a different hook alist, namely, 592 =embark-pre-action-hooks=. 593 594 Besides =embark--allow-edit=, Embark comes with another function that is 595 of general utility in action setup hooks: =embark--ignore-target=. Use 596 it for commands that do prompt you in the minibuffer but for which 597 inserting the target would be inappropriate. This is not a common 598 situation but does occasionally arise. For example it is used by 599 default for =shell-command-on-region=: that command is used as an action 600 for region targets, and it prompts you for a shell command; you 601 typically do /not/ want the target, that is the contents of the region, 602 to be entered at that prompt! 603 604 ** Running hooks before, after or around an action 605 606 Embark has three variables, =embark-pre-action-hooks=, 607 =embark-post-action-hooks= and =embark-around-action-hooks=, which are 608 alists associating commands to hooks that should run before or after 609 or as around advice for the command when used as an action. As with 610 =embark-target-injection-hooks=, there are two special keys for the 611 alists: =t= designates the default hook to run when no specific hook is 612 specified for a command; and the hook associated to =:always= runs 613 regardless. 614 615 The default values of those variables are fairly extensive, adding 616 creature comforts to make running actions a smooth experience. Embark 617 comes with several functions intended to be added to these hooks, and 618 used in the default values of =embark-pre-action-hooks=, 619 =embark-post-action-hooks= and =embark-around-action-hooks=. 620 621 For pre-action hooks: 622 623 - =embark--confirm= :: Prompt the user for confirmation before executing 624 the action. This is used be default for commands deemed "dangerous", 625 or, more accurately, hard to undo, such as =delete-file= and 626 =kill-buffer=. 627 628 - =embark--unmark-target= :: Unmark the active region. Use this for 629 commands you want to act on the region contents but without the 630 region being active. The default configuration uses this function as 631 a pre-action hook for =occur= and =query-replace=, for example, so that 632 you can use them as actions with region targets to search the whole 633 buffer for the text contained in the region. Without this pre-action 634 hook using =occur= as an action for a region target would be 635 pointless: it would search for the the region contents /in the 636 region/, (typically, due to the details of regexps) finding only one 637 match! 638 639 - =embark--beginning-of-target= :: Move to the beginning of the target 640 (for targets that report bounds). This is used by default for 641 backward motion commands such as =backward-sexp=, so that they don't 642 accidentally leave you on the current target. 643 644 - =embark--end-of-target= :: Move to the end of the target. This is used 645 similarly to the previous function, but also for commands that act 646 on the last s-expression like =eval-last-sexp=. This allow you to act 647 on an s-expression from anywhere inside it and still use 648 =eval-last-sexp= as an action. 649 650 - =embark--xref-push-markers= :: Push the current location on the xref 651 marker stack. Use this for commands that take you somewhere and for 652 which you'd like to be able to come back to where you were using 653 =xref-pop-marker-stack=. This is used by default for =find-library=. 654 655 For post-action hooks: 656 657 - =embark--restart= :: Restart the command currently prompting in the 658 minibuffer, so that the list of completion candidates is updated. 659 This is useful as a post action hook for commands that delete or 660 rename a completion candidate; for example the default value of 661 =embark-post-action-hooks= uses it for =delete-file=, =kill-buffer=, 662 =rename-file=, =rename-buffer=, etc. 663 664 For around-action hooks: 665 666 - =embark--mark-target= :: Save existing mark and point location, mark 667 the target and run the action. Most targets at point outside the 668 minibuffer report which region of the buffer they correspond to 669 (this is the information used by =embark-highlight-indicator= to 670 know what portion of the buffer to highlight); this function marks 671 that region. It is useful as an around action hook for commands that 672 expect a region to be marked, for example, it is used by default for 673 =indent-region= so that it works on s-expression targets, or for 674 =fill-region= so that it works on paragraph targets. 675 676 - =embark--cd= :: Run the action with =default-directory= set to the 677 directory associated to the current target. The target should be of 678 type =file=, =buffer=, =bookmark= or =library=, and the associated directory 679 is what you'd expect in each case. 680 681 - =embark--narrow-to-target= :: Run the action with buffer narrowed to 682 current target. Use this as an around hook to localize the effect of 683 actions that don't already work on just the region. In the default 684 configuration it is used for =repunctuate-sentences=. 685 686 - =embark--save-excursion= :: Run the action restoring point at the end. 687 The current default configuration doesn't use this but it is 688 available for users. 689 690 ** Creating your own keymaps 691 692 All internal keymaps are defined with the standard helper macro 693 =defvar-keymap=. For example a simple version of the file action keymap 694 could be defined as follows: 695 696 #+BEGIN_SRC emacs-lisp 697 (defvar-keymap embark-file-map 698 :doc "Example keymap with a few file actions" 699 :parent embark-general-map 700 "d" #'delete-file 701 "r" #'rename-file 702 "c" #'copy-file) 703 #+END_SRC 704 705 These action keymaps are perfectly normal Emacs 706 keymaps. You may want to inherit from the =embark-general-map= if you 707 want to access the default Embark actions. Note that =embark-collect= 708 and =embark-export= are also made available via =embark-general-map=. 709 710 ** Defining actions for new categories of targets 711 712 It is easy to configure Embark to provide actions for new types of 713 targets, either in the minibuffer or outside it. I present below two 714 very detailed examples of how to do this. At several points I'll 715 explain more than one way to proceed, typically with the easiest 716 option first. I include the alternative options since there will be 717 similar situations where the easiest option is not available. 718 719 *** New minibuffer target example - tab-bar tabs 720 721 As an example, take the new [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Tab-Bars.html][tab bars]] from Emacs 27. I'll explain how 722 to configure Embark to offer tab-specific actions when you use the 723 tab-bar-mode commands that mention tabs by name. The configuration 724 explained here is now built-in to Embark (and Marginalia), but it's 725 still a good self-contained example. In order to setup up tab actions 726 you would need to: (1) make sure Embark knows those commands deal with 727 tabs, (2) define a keymap for tab actions and configure Embark so it 728 knows that's the keymap you want. 729 730 **** Telling Embark about commands that prompt for tabs by name 731 732 For step (1), it would be great if the =tab-bar-mode= commands reported 733 the completion category =tab= when asking you for a tab with 734 completion. (All built-in Emacs commands that prompt for file names, 735 for example, do have metadata indicating that they want a =file=.) They 736 do not, unfortunately, and I will describe a couple of ways to deal 737 with this. 738 739 Maybe the easiest thing is to configure [[https://github.com/minad/marginalia][Marginalia]] to enhance those 740 commands. All of the =tab-bar-*-tab-by-name= commands have the words 741 "tab by name" in the minibuffer prompt, so you can use: 742 743 #+begin_src emacs-lisp 744 (add-to-list 'marginalia-prompt-categories '("tab by name" . tab)) 745 #+end_src 746 747 That's it! But in case you are ever in a situation where you don't 748 already have commands that prompt for the targets you want, I'll 749 describe how writing your own command with appropriate =category= 750 metadata looks: 751 752 #+begin_src emacs-lisp 753 (defun my-select-tab-by-name (tab) 754 (interactive 755 (list 756 (let ((tab-list (or (mapcar (lambda (tab) (cdr (assq 'name tab))) 757 (tab-bar-tabs)) 758 (user-error "No tabs found")))) 759 (completing-read 760 "Tabs: " 761 (lambda (string predicate action) 762 (if (eq action 'metadata) 763 '(metadata (category . tab)) 764 (complete-with-action 765 action tab-list string predicate))))))) 766 (tab-bar-select-tab-by-name tab)) 767 #+end_src 768 769 As you can see, the built-in support for setting the category 770 meta-datum is not very easy to use or pretty to look at. To help with 771 this I recommend the =consult--read= function from the excellent 772 [[https://github.com/minad/consult/][Consult]] package. With that function we can rewrite the command as 773 follows: 774 775 #+begin_src emacs-lisp 776 (defun my-select-tab-by-name (tab) 777 (interactive 778 (list 779 (let ((tab-list (or (mapcar (lambda (tab) (cdr (assq 'name tab))) 780 (tab-bar-tabs)) 781 (user-error "No tabs found")))) 782 (consult--read tab-list 783 :prompt "Tabs: " 784 :category 'tab)))) 785 (tab-bar-select-tab-by-name tab)) 786 #+end_src 787 788 Much nicer! No matter how you define the =my-select-tab-by-name= 789 command, the first approach with Marginalia and prompt detection has 790 the following advantages: you get the =tab= category for all the 791 =tab-bar-*-bar-by-name= commands at once, also, you enhance built-in 792 commands, instead of defining new ones. 793 794 **** Defining and configuring a keymap for tab actions 795 796 Let's say we want to offer select, rename and close actions for tabs 797 (in addition to Embark general actions, such as saving the tab name to 798 the kill-ring, which you get for free). Then this will do: 799 800 #+begin_src emacs-lisp 801 (defvar-keymap embark-tab-actions 802 :doc "Keymap for actions for tab-bar tabs (when mentioned by name)." 803 :parent embark-general-map 804 "s" #'tab-bar-select-tab-by-name 805 "r" #'tab-bar-rename-tab-by-name 806 "k" #'tab-bar-close-tab-by-name) 807 808 (add-to-list 'embark-keymap-alist '(tab . embark-tab-actions)) 809 #+end_src 810 811 What if after using this for a while you feel closing the tab 812 without confirmation is dangerous? You have a couple of options: 813 814 1. You can keep using the =tab-bar-close-tab-by-name= command, but have 815 Embark ask you for confirmation: 816 #+begin_src emacs-lisp 817 (push #'embark--confirm 818 (alist-get 'tab-bar-close-tab-by-name 819 embark-pre-action-hooks)) 820 #+end_src 821 822 2. You can write your own command that prompts for confirmation and 823 use that instead of =tab-bar-close-tab-by-name= in the above keymap: 824 #+begin_src emacs-lisp 825 (defun my-confirm-close-tab-by-name (tab) 826 (interactive "sTab to close: ") 827 (when (y-or-n-p (format "Close tab '%s'? " tab)) 828 (tab-bar-close-tab-by-name tab))) 829 #+end_src 830 831 Notice that this is a command you can also use directly from =M-x= 832 independently of Embark. Using it from =M-x= leaves something to be 833 desired, though, since you don't get completion for the tab names. 834 You can fix this if you wish as described in the previous section. 835 836 *** New target example in regular buffers - short Wikipedia links 837 838 Say you want to teach Embark to treat text of the form 839 =wikipedia:Garry_Kasparov= in any regular buffer as a link to Wikipedia, 840 with actions to open the Wikipedia page in eww or an external browser 841 or to save the URL of the page in the kill-ring. We can take advantage 842 of the actions that Embark has preconfigured for URLs, so all we need 843 to do is teach Embark that =wikipedia:Garry_Kasparov= stands for the URL 844 =https://en.wikipedia.org/wiki/Garry_Kasparov=. 845 846 You can be as fancy as you want with the recognized syntax. Here, to 847 keep the example simple, I'll assume the link matches the regexp 848 =wikipedia:[[:alnum:]_]+=. We will write a function that looks for a 849 match surrounding point, and returns a dotted list of the form ='(url 850 URL-OF-THE-PAGE START . END)= where =START= and =END= are the buffer 851 positions bounding the target, and are used by Embark to highlight it 852 if you have =embark-highlight-indicator= included in the list 853 =embark-indicators=. (There are a couple of other options for the return 854 value of a target finder: the bounding positions are optional and a 855 single target finder is allowed to return multiple targets; see the 856 documentation for =embark-target-finders= for details.) 857 858 #+begin_src emacs-lisp 859 (defun my-short-wikipedia-link () 860 "Target a link at point of the form wikipedia:Page_Name." 861 (save-excursion 862 (let* ((start (progn (skip-chars-backward "[:alnum:]_:") (point))) 863 (end (progn (skip-chars-forward "[:alnum:]_:") (point))) 864 (str (buffer-substring-no-properties start end))) 865 (save-match-data 866 (when (string-match "wikipedia:\\([[:alnum:]_]+\\)" str) 867 `(url 868 ,(format "https://en.wikipedia.org/wiki/%s" 869 (match-string 1 str)) 870 ,start . ,end)))))) 871 872 (add-to-list 'embark-target-finders 'my-short-wikipedia-link) 873 #+end_src 874 875 * How does Embark call the actions? 876 877 Embark actions are normal Emacs commands, that is, functions with an 878 interactive specification. In order to execute an action, Embark 879 calls the command with =call-interactively=, so the command reads user 880 input exactly as if run directly by the user. For example the 881 command may open a minibuffer and read a string 882 (=read-from-minibuffer=) or open a completion interface 883 (=completing-read=). If this happens, Embark takes the target string 884 and inserts it automatically into the minibuffer, simulating user 885 input this way. After inserting the string, Embark exits the 886 minibuffer, submitting the input. (The immediate minibuffer exit can 887 be disabled for specific actions in order to allow editing the 888 input; this is done by adding the =embark--allow-edit= function to the 889 appropriate entry of =embark-target-injection-hooks=). Embark inserts 890 the target string at the first minibuffer opened by the action 891 command, and if the command happens to prompt the user for input 892 more than once, the user still interacts with the second and further 893 prompts in the normal fashion. Note that if a command does not 894 prompt the user for input in the minibuffer, Embark still allows you 895 to use it as an action, but of course, never inserts the target 896 anywhere. (There are plenty of examples in the default configuration 897 of commands that do not prompt the user bound to keys in the action 898 maps, most of the region actions, for instance.) 899 900 This is how Embark manages to reuse normal commands as actions. The 901 mechanism allows you to use as Embark actions commands that were not 902 written with Embark in mind (and indeed almost all actions that are 903 bound by default in Embark's action keymaps are standard Emacs 904 commands). It also allows you to write new custom actions in such a 905 way that they are useful even without Embark. 906 907 Staring from version 28.1, Emacs has a variable 908 =y-or-n-p-use-read-key=, which when set to =t= causes =y-or-n-p= to use 909 =read-key= instead of =read-from-minibuffer=. Setting 910 =y-or-n-p-use-read-key= to =t= is recommended for Embark users because 911 it keeps Embark from attempting to insert the target at a =y-or-n-p= 912 prompt, which would almost never be sensible. Also consider this as 913 a warning to structure your own action commands so that if they use 914 =y-or-n-p=, they do so only after the prompting for the target. 915 916 Here is a simple example illustrating the various ways of reading 917 input from the user mentioned above. Bind the following commands to 918 the =embark-symbol-map= to be used as actions, then put the point on 919 some symbol and run them with =embark-act=: 920 921 #+begin_src emacs-lisp 922 (defun example-action-command1 () 923 (interactive) 924 (message "The input was `%s'." (read-from-minibuffer "Input: "))) 925 926 (defun example-action-command2 (arg input1 input2) 927 (interactive "P\nsInput 1: \nsInput 2: ") 928 (message "The first input %swas `%s', and the second was `%s'." 929 (if arg "truly " "") 930 input1 931 input2)) 932 933 (defun example-action-command3 () 934 (interactive) 935 (message "Your selection was `%s'." 936 (completing-read "Select: " '("E" "M" "B" "A" "R" "K")))) 937 938 (defun example-action-command4 () 939 (interactive) 940 (message "I don't prompt you for input and thus ignore the target!")) 941 942 (keymap-set embark-symbol-map "X 1" #'example-action-command1) 943 (keymap-set embark-symbol-map "X 2" #'example-action-command2) 944 (keymap-set embark-symbol-map "X 3" #'example-action-command3) 945 (keymap-set embark-symbol-map "X 4" #'example-action-command4) 946 #+end_src 947 948 Also note that if you are using the key bindings to call actions, 949 you can pass prefix arguments to actions in the normal way. For 950 example, you can use =C-u X2= with the above demonstration actions to 951 make the message printed by =example-action-command2= more emphatic. 952 This ability to pass prefix arguments to actions is useful for some 953 actions in the default configuration, such as 954 =embark-shell-command-on-buffer=. 955 956 ** Non-interactive functions as actions 957 958 Alternatively, Embark does support one other type of action: a 959 non-interactive function of a single argument. The target is passed 960 as argument to the function. For example: 961 962 #+begin_src emacs-lisp 963 (defun example-action-function (target) 964 (message "The target was `%s'." target)) 965 966 (keymap-set embark-symbol-map "X 4" #'example-action-function) 967 #+end_src 968 969 Note that normally binding non-interactive functions in a keymap is 970 useless, since when attempting to run them using the key binding you 971 get an error message similar to "Wrong type argument: commandp, 972 example-action-function". In general it is more flexible to write 973 any new Embark actions as commands, that is, as interactive 974 functions, because that way you can also run them directly, without 975 Embark. But there are a couple of reasons to use non-interactive 976 functions as actions: 977 978 1. You may already have the function lying around, and it is 979 convenient to simply reuse it. 980 981 2. For command actions the targets can only be simple string, with 982 no text properties. For certain advanced uses you may want the 983 action to receive a string /with/ some text properties, or even a 984 non-string target. 985 986 * Embark, Marginalia and Consult 987 988 Embark cooperates well with the [[https://github.com/minad/marginalia][Marginalia]] and [[https://github.com/minad/consult][Consult]] packages. 989 Neither of those packages is a dependency of Embark, but both are 990 highly recommended companions to Embark, for opposite reasons: 991 Marginalia greatly enhances Embark's usefulness, while Embark can help 992 enhance Consult. 993 994 In the remainder of this section I'll explain what exactly Marginalia 995 does for Embark, and what Embark can do for Consult. 996 997 ** Marginalia 998 999 Embark comes with actions for symbols (commands, functions, variables 1000 with actions such as finding the definition, looking up the 1001 documentation, evaluating, etc.) in the =embark-symbol-map= keymap, and 1002 for packages (actions like install, delete, browse url, etc.) in the 1003 =embark-package-keymap=. 1004 1005 Unfortunately Embark does not automatically offers you these keymaps 1006 when relevant, because many built-in Emacs commands don't report 1007 accurate category metadata. For example, a command like 1008 =describe-package=, which reads a package name from the minibuffer, 1009 does not have metadata indicating this fact. 1010 1011 In an earlier Embark version, there were functions to supply this 1012 missing metadata, but they have been moved to Marginalia, which 1013 augments many Emacs command to report accurate category metadata. 1014 Simply activating =marginalia-mode= allows Embark to offer you the 1015 package and symbol actions when appropriate again. Candidate 1016 annotations in the Embark collect buffer are also provided by the 1017 Marginalia package: 1018 1019 - If you install Marginalia and activate =marginalia-mode=, Embark 1020 Collect buffers will use the Marginalia annotations automatically. 1021 1022 - If you don't install Marginalia, you will see only the annotations 1023 that come with Emacs (such as key bindings in =M-x=, or the unicode 1024 characters in =C-x 8 RET=). 1025 1026 ** Consult 1027 1028 The excellent Consult package provides many commands that use 1029 minibuffer completion, via the =completing-read= function; plenty of its 1030 commands can be considered enhanced versions of built-in Emacs 1031 commands, and some are completely new functionality. One common 1032 enhancement provided in all commands for which it makes sense is 1033 preview functionality, for example =consult-buffer= will show you a 1034 quick preview of a buffer before you actually switch to it. 1035 1036 If you use both Consult and Embark you should install the 1037 =embark-consult= package which provides integration between the two. It 1038 provides exporters for several Consult commands and also tweaks the 1039 behavior of many Consult commands when used as actions with =embark-act= 1040 in subtle ways that you may not even notice, but make for a smoother 1041 experience. You need only install it to get these benefits: Embark 1042 will automatically load it after Consult if found. 1043 1044 The =embark-consult= package provides the following exporters: 1045 1046 - You can use =embark-export= from =consult-line=, =consult-outline=, or 1047 =consult-mark= to obtain an =occur-mode= buffer. As with the built-in 1048 =occur= command you use that buffer to jump to a match and after that, 1049 you can then use =next-error= and =previous-error= to navigate to other 1050 matches. You can also press =e= to activate =occur-edit-mode= and edit 1051 the matches in place! 1052 1053 - You can export from any of the Consult asynchronous search commands, 1054 =consult-grep=, =consult-git-grep=, or =consult-ripgrep= to get a 1055 =grep-mode= buffer. Here too you can use =next-error= and =previous-error= 1056 to navigate among matches, and, if you install the [[http://github.com/mhayashi1120/Emacs-wgrep/raw/master/wgrep.el ][wgrep]] package, 1057 you can use it to edit the matches in place. 1058 1059 In both cases, pressing =g= will rerun the Consult command you had 1060 exported from and re-enter the input you had typed (which is similar 1061 to reverting but a little more flexible). You can then proceed to 1062 re-export if that's what you want, but you can also edit the input 1063 changing the search terms or simply cancel if you see you are done 1064 with that search. 1065 1066 The =embark-consult= also contains some candidates collectors that allow 1067 you to run =embark-live= to get a live-updating table of contents for 1068 your buffer: 1069 1070 - =embark-consult-outline-candidates= produces the outline headings of 1071 the current buffer, using =consult-outline=. 1072 - =embark-consult-imenu-candidates= produces the imenu items of 1073 the current buffer, using =consult-imenu=. 1074 - =embark-consult-imenu-or-outline-candidates= is a simple combination 1075 of the two previous functions: it produces imenu items in buffers 1076 deriving from =prog-mode= and otherwise outline headings. 1077 1078 The way to configure =embark-live= (or =embark-collect= and =embark-export= 1079 for that matter) to use one of these function is to add it at the end 1080 of the =embark-candidate-collectors= list. The =embark-consult= package by 1081 default adds the last one, which seems to be the most sensible 1082 default. 1083 1084 Besides those exporters and candidate collectors, the =embark-consult= 1085 package provides many subtle tweaks and small integrations between 1086 Embark and Consult. Some examples are: 1087 1088 - The asynchronous search commands will start in the directory 1089 associated to the Embark target if that target is a file, buffer, 1090 bookmark or Emacs Lisp library. 1091 1092 - For all other target types, a Consult search command (asynchronous 1093 or not) will search for the text of the target but leave the 1094 minibuffer open so you can interact with the Consult command. 1095 1096 - =consult-imenu= will search for the target and take you directly to 1097 the location if it matches a unique imenu entry, otherwise it will 1098 leave the minibuffer open so you can navigate among the matches. 1099 1100 * Resources 1101 1102 If you want to learn more about how others have used Embark here are 1103 some links to read: 1104 1105 - [[https://karthinks.com/software/fifteen-ways-to-use-embark/][Fifteen ways to use Embark]], a blog post by Karthik Chikmagalur. 1106 - [[https://protesilaos.com/dotemacs/][Protesilaos Stavrou's dotemacs]], look for the section called 1107 "Extended minibuffer actions and more (embark.el and 1108 prot-embark.el)" 1109 1110 And some videos to watch: 1111 1112 - [[https://protesilaos.com/codelog/2021-01-09-emacs-embark-extras/][Embark and my extras]] by Protesilaos Stavrou. 1113 - [[https://youtu.be/qpoQiiinCtY][Embark -- Key features and tweaks]] by Raoul Comninos on the 1114 Emacs-Elements YouTube channel. 1115 - [[https://youtu.be/WsxXr1ncukY][Livestreamed: Adding an Embark context action to send a stream 1116 message]] by Sacha Chua. 1117 - [[https://youtu.be/qk2Is_sC8Lk][System Crafters Live! - The Many Uses of Embark]] by David Wilson. 1118 - [[https://youtu.be/5ffb2at2d7w][Using Emacs Episode 80 - Vertico, Marginalia, Consult and Embark]] by 1119 Mike Zamansky. 1120 1121 * Contributions 1122 1123 Contributions to Embark are very welcome. There is a [[https://github.com/oantolin/embark/issues/95][wish list]] for 1124 actions, target finders, candidate collectors and exporters. For other 1125 ideas you have for Embark, feel free to open an issue on the [[https://github.com/oantolin/embark/issues][issue 1126 tracker]]. Any neat configuration tricks you find might be a good fit 1127 for the [[https://github.com/oantolin/embark/wiki][wiki]]. 1128 1129 Code contributions are very welcome too, but since Embark is now on 1130 GNU ELPA, copyright assignment to the FSF is required before you can 1131 contribute code. 1132 1133 * Acknowledgments 1134 1135 While I, Omar Antolín Camarena, have written most of the Embark code 1136 and remain very stubborn about some of the design decisions, Embark 1137 has received substantial help from a number of other people which this 1138 document has neglected to mention for far too long. In particular, 1139 Daniel Mendler has been absolutely invaluable, implementing several 1140 important features, and providing a lot of useful advice. 1141 1142 Code contributions: 1143 1144 - [[https://github.com/minad][Daniel Mendler]] 1145 - [[https://github.com/clemera/][Clemens Radermacher]] 1146 - [[https://codeberg.org/jao/][José Antonio Ortega Ruiz]] 1147 - [[https://github.com/iyefrat][Itai Y. Efrat]] 1148 - [[https://github.com/a13][a13]] 1149 - [[https://github.com/jakanakaevangeli][jakanakaevangeli]] 1150 - [[https://github.com/mihakam][mihakam]] 1151 - [[https://github.com/leungbk][Brian Leung]] 1152 - [[https://github.com/karthink][Karthik Chikmagalur]] 1153 - [[https://github.com/roshanshariff][Roshan Shariff]] 1154 - [[https://github.com/condy0919][condy0919]] 1155 - [[https://github.com/DamienCassou][Damien Cassou]] 1156 - [[https://github.com/JimDBh][JimDBh]] 1157 1158 Advice and useful discussions: 1159 1160 - [[https://github.com/minad][Daniel Mendler]] 1161 - [[https://gitlab.com/protesilaos/][Protesilaos Stavrou]] 1162 - [[https://github.com/clemera/][Clemens Radermacher]] 1163 - [[https://github.com/hmelman/][Howard Melman]] 1164 - [[https://github.com/astoff][Augusto Stoffel]] 1165 - [[https://github.com/bdarcus][Bruce d'Arcus]] 1166 - [[https://github.com/jdtsmith][JD Smith]] 1167 - [[https://github.com/karthink][Karthik Chikmagalur]] 1168 - [[https://github.com/jakanakaevangeli][jakanakaevangeli]] 1169 - [[https://github.com/iyefrat][Itai Y. Efrat]] 1170 - [[https://github.com/mohkale][Mohsin Kaleem]]