Embark for Emacs seems like a useful way to further customize Emacs actions (M-x
). I still don’t understand why I would want to use it, so this note is an exploration to try it out and see if it’s useful.
What can you do with embark
?
I’m still figuring out what will be most useful for me, but I’m keeping a running log of what I find below.
Cherry-picking results
Select a custom set of results from a list of completions and export it into a new buffer to use later. For example, I can search org-roam for notes I need to complete that are tagged with #draft
and then use embark
to select a few notes I want to work on. Embark persists this new list in a buffer I can return to later.
Compose results
We can extend the above technique to build up a customized list of items from multiple searches. For example, I can start a search for notes about “AI”, select some results (C-. SPC
), then search for LLMs and select those results, thereby accumulating the items across multiple searches. Invoking embark-export
puts that in a new buffer to go through later just as before.
You can view the intermediate results by using embark-live
.
Quirks:
- Unfortunately, the results won’t update the live list unless the search query is changed.
- I can’t seem to select all items from the search results without exporting a new buffer.
- I would love to be able to come back to an export and add more to it later, but there doesn’t seem to be a way to do that.
Narrow down results
Methodically narrow down a large list of results you don’t want to lose, export a sublist, and then work on that without losing your history.
Add contextual actions
I want to use embark
to select a region and fix all the grammar and spelling mistakes using gptel
(see ways to use AI with Emacs).
(I haven’t done this yet but am planning to try and extend the list of actions.)
Maintaining flow
Sometimes you’re in the minibuffer and realize there was something else you needed to do on the same item. Rather than exit (C-g
), use embark
to take another action instead and come back to what you were doing (C-u C-.
).
You can even use another action that isn’t already defined by calling M-x
and come right back to where you were.
Create a new note with a title from the selected region
Select some text and then use embark
to insert a new org-roam
note using the text as the title (C-. M-x org-roam-node-insert
).
Other thoughts
Embark is close to a “universal interface” for invoking actions on items. The completions framework that Emacs introduced makes it possible for Embark to operate on anything using exactly the same pattern. What’s incredible is that means nothing in Emacs needs to be updated to work with Embark.
I’m starting to think this is a rather important discovery for UX. Search is the first step; what you do with it next is the second half.
Embark broke my brain at first, but it makes a lot more sense when you try to use it. Notice how it seems to just work everywhere and in ways that you would expect. Files, buffers, links, search, etc.
I was worried that this would all feel very modal and require rote memorization to do anything useful. Somehow it doesn’t feel like that because it’s all operating on text and a limited set of object types at the end of the day. Even if it is modal, there are not that many modes.
See also:
- Emacs is the ultimate editor building material
- Fifteen ways to use embark describes
embark
as the “actually” and “but first” command