Embark Usage

Yusef Aslam - 24 Apr 2024

Tags: emacs,embark

Embark usage

The Github Page is extremely useful to understand embark. I have it downloaded here.

embark-dwim

There is also embark-dwim which runs the default action for the first target found. It’s pretty handy in non-minibuffer buffers: with Embark’s default configuration it will:

  • Open the file at point.
  • Open the URL at point in a web browser (using the browse-url command).
  • Compose a new email to the email address at point.
  • In an Emacs Lisp buffer, if point is on an opening parenthesis or right after a closing one, it will evaluate the corresponding expression.
  • Go to the definition of an Emacs Lisp function, variable or macro at point.
  • Find the file corresponding to an Emacs Lisp library at point.

I have it bound to M-. as recommended in the README.

embark-consult

Embark Integration - Consult Github Page https://github.com/oantolin/embark?tab=readme-ov-file#consult Consult - Embark README

  • consult-line -> embark-export to occur-mode buffer -> occur-edit-mode for editing of matches in buffer.
  • consult-grep -> embark-export to grep-mode buffer -> wgrep for editing of all matches.
  • consult-find -> embark-export to dired-mode buffer -> wdired-change-to-wdired-mode for editing.

embark-live

  • Can be used to provide a live updating buffer list like ibuffer. C-x b (switch-to-buffer) -> L (embark-live)
  • Or a live updating header list, like imenu. M-g i (imenu) -> C-. (embark-act) -> L (embark-live) (doesn’t work) Running just embark-live does work though.

embark-become

For when your lazy and don’t want to retype a filename when you used switch-to-buffer instead of find-file. Just become find-file from switch-to-buffer!

embark-export or embark-collect?

When in doubt choosing between exporting and collecting, a good rule of thumb is to always prefer embark-export since when an exporter to a special major mode is available for a given type of target, it will be more featureful than an Embark collect buffer, and if no such exporter is configured the embark-export command falls back to the generic embark-collect.

scrolling in embark-act?

By default, if you run embark-act and do not immediately select an action, after a short delay Embark will pop up a buffer called Embark Actions containing a list of available actions with their key bindings. You can scroll that buffer with the mouse of with the usual commands scroll-other-window and scroll-other-window-down (bound by default to C-M-v and C-M-S-v).

creating an ad-hoc completion set with embark-select and embark-act-all

The selection functionality is supported in every buffer:

  • In the minibuffer this gives a convenient way to act on several completion candidates that don’t follow any simple pattern: just go through the completions selecting the ones you want, then use embark-act-all. For example, you could attach several files at once to an email.
  • For Embark Collect buffers this functionality enables a dired-like workflow, in which you mark various candidates and apply an action to all at once. (It supersedes a previous ad hoc dired-like interface that was implemented only in Embark Collect buffers, with a slightly different interface.)
  • In a eww buffer you could use this to select various links you wish to follow up on, and then collect them into a buffer. Similarly, while reading Emacs’s info manual you could select some symbols you want to read more about and export them to an apropos-mode buffer.
  • You can use selections in regular text or programming buffers to do complex editing operations. For example, if you have three paragraphs scattered over a file and you want to bring them together, you can select each one, insert them all somewhere and finally delete all of them (from their original locations).

Issue

Why does embark-act-all then E (embark-export) spawn multiple buffers?

  • I’m using it wrong, you select the stuff, then don’t run embark-act-all, run embark-export.

  • You only use embark-act-all for when you want to, for example, append your selections to a file. (+ in embark-act-all)

Regenerated at : January 20, 2025 - 17:31:39 GMT