reddit / emacs

Narrow buffers using path (Doom+vertico)

the_whalerus · 2022-03-08 16:51
I'm using Doom Emacs, and I'd like `+vertico/switch-workspace-buffer` to let me narrow stuff by path. I have a million files at work all called `index.js` and searching through buffers using the path would be really helpful for that. I couldn't find an option for it.
00-11 · 2022-03-08 19:58
Dunno about Vertico or Doom; sorry. If you use [Icicles](https://www.emacswiki.org/emacs/Icicles) then you can use `C-x R` when [completing against buffer names](https://www.emacswiki.org/emacs/Icicles_-_Buffer-Name_Input) (e.g. with `C-x b`), to include recently used (absolute) file names among the completion candidates. That will let you match against their paths. (It's a toggle, so `C-x R` again removes recent files as buffer candidates.)
dpoggio · 2022-03-08 20:42
2 options: a) If you’re sticking to Vertico, maybe renaming your buffers to match the full path is wise. You can do it on a lambda bound to the same keybinding, and then call your vertico function. b) use `ibuffer-list-buffers`, then `s f` to sort by filename/process or just use your favorite search utility.
organic-bookworm · 2022-03-08 20:46
You could include file paths in buffer names (setq uniquify-buffer-name-style 'forward) This way files `/path/to/dir1/index.js` and `/path/to/dir2/index.js` would open as buffers named `dir1/index.js` and `dir2/index.js` accordingly.
organic-bookworm · 2022-03-08 21:19
Hmm, apparently, Doom sets this by default. However, it turns this off for `persp-mode` due to potential [serialization issues](https://github.com/hlissner/doom-emacs/pull/1506#pullrequestreview-253133166). >a bug in persp-mode causes buffers renamed by uniquify to throw errors when switching between perspective (their buffers are serialized by name, and persp-mode expects them to have the same name when restored).