ExistingProgram3883 · 2022-03-03 08:57
Dear community,
I have a quick question regarding multiple selections with `consult`:
Helm Buffer has a feature which allows selecting multiple buffers via `C-SPC` in order to kill those at once with `M-D` (see [here](https://rnchzn.github.io/helm/doc/helm-manual.html#Commands)). Does `consult-buffer` provide a comparable feature? If so, how could I access it?
Furthermore, I would like to generalize the question: Given any `consult-*` command, how can I select multiple items and act on those with the help of `embark`?
Thanks in advance!
emax-gomax · 2022-03-03 13:25
I don't think consult has the concept of marking candidates. In the embark readme there's a section where they suggest creating a cmd dolls embark-act but with `embark-exit` (or some var like that) set to nil so embark doesn't quit the minibuffer after it's done. Now instead of marking, you just run the binding for whatever candidate you want and keep selecting other candidates. Honestly I'd prefer marking but since moving to consult I rarely have the need to do it anymore. Exporting to a dedicated buffer and manually cycling through has been working pretty well for me.
bdarcus · 2022-03-03 14:05
There has been [discussion](https://github.com/oantolin/embark/issues/166) about adding this capability to Embark, which is really where it belongs.
See [this post](https://github.com/oantolin/embark/issues/166#issuecomment-1058044854) for an example you can try in your config in the meantime.
ExistingProgram3883 · 2022-03-03 19:27
Thanks for helping again, Bruce!
The code works like a treat. Good to hear, that it will become part of `embark`. Do you have any tip to quickly switch into embark's collect buffer when the minibuffer is open since `other-window` (`C-x o`) is not working in that case?
For anybody who wants to try the code linked by u/bdarcus/ quickly as well, run the following commands after having evaluated the code:
- `M-x consult-*`
- `embark-act`
- `embark-collect-live` via `L`
- `+embark-mark` via `m`
- `embark-act-all` via `A`
karthink · 2022-03-03 19:58
`embark-collect-live` will be removed from Embark soon. Also I recommend setting a binding for `embark-collect-snapshot`, so that you can do
- Any minibuffer command, `M-x `
- Export to collect buffer with `C-l` (say)
- Mark candidates with `m` like you would in dired or ibuffer
- Run `embark-act-all`
oantolin · 2022-03-04 01:23
As others have said marking functionality will be added pretty soon to Embark, for people who prefer that exact work flow, but let me just point out there are already plenty of ways to achieve equivalent functionality.
1. Run `embark-act` on each candidate you do wish to act on as a non-quitting action. To have `embark-act` not quit the minibuffer you can `(setq embark-quit-after-action nil)` or keep it at the default value of `t` and use `C-u` each time. This bare bones method has the added flexibility that you don't have to use the same action on each candidate but it is a little verbose.
2. Narrow to exactly the candidates you want and then use `embark-act-all`. If you use orderless this often pretty convenient. I usually find that when I want to run the same action on a bunch of candidates it's all candidates matching some pattern with one or two exceptions, so I type in the pattern and then add a couple of negative literals to exclude the false positives.
3. If the candidates are files or buffers you can use `embark-export` to get a dired or ibuffer buffer, then press mark the ones you want and perform the action. Often you can just use dired or ibuffer commands to perform the action, but remember that `embark-act-all` works in dired and ibuffer too, and acts only on the marked items. This is convenient for actions that Embark has keybindings for but dired or ibuffer don't, such as `vc-delete-file`.
4. You can use `embark-collect-snapshot` (which, as part of the changes u/karthink mentioned that are coming soon will be renamed `embark-collect`) and then act on the candidates in the collect buffer. To make the actions simpler to specify there, you can turn on `embark-collect-direct-action-minor-mode` (bound by default to `A`), which let's you directly use the embark action key bindings without running `embark-act` first.
I think I most often use methods 1 and 2: I use 1 if its only a couple of candidates or if I haven't really planned ahead, and 2 most of the rest of the time.
oantolin · 2022-03-24 05:41
Quick update: the marking functionality has been added to Embark Collect buffers now (in the version on MELPA, not on GNU ELPA just yet). The bindings are dired-like (and ibuffer-like): `m` to mark a candidate, `u` to unmark, `t` to toggle marks and `U` to unmark all. In Embark Collect buffers `embark-act-all` is now bound to `A` (the old binding of `A`, namely, `embark-collect-direct-action-minor-mode`, has been moved to `M-a`), and if any candidate is marked `embark-act-all` acts only on marked candidates ---and when none are marked it acts on all candidates, as before.
ExistingProgram3883 · 2022-06-03 05:24
I want to express my gratitude for that feature. For my workflow, this is very useful. Thanks for building this into `embark`, u/oantolin!