Emacs: decent defaults I shared with Sacha Chua
1mon 10d ago by sh.itjust.works/u/NanoooK in emacs@lemmy.ml from protesilaos.com
Every blog post like this contains a bunch of new variables I've never heard of but always wanted. Like help-window-keep-selected or window-combination-resize.
Putting that aside though, am I the only one who likes the built-in completions buffer?
(use-package minibuffer
:custom
(completions-format 'one-column)
(completions-sort 'historical) ; Emacs 30
(completions-max-height 20)
(completion-styles '(basic partial-completion substring))
(completion-auto-select t)
(completion-ignore-case t))
I like that it doesn't move the modeline up for completion and that it feels like shell completion. It also works for completion at-point.
The variable completion-auto-select is load bearing for my workflow though, before I knew about it I very much thought I needed icomplete or vertico.
I tend to like it, too (though I can't tell if that's just because it's what I first used and now I just expect it to work that way, now…).
Do you know if there's a way to go backwards through available options, though? I forget what shift+tab does but its not the inverse of tab and having to cycle all the way through to come back around on a particularly large list of options sure is tedious.
I think that's just about my only complaint with the default.
Shift-Tab just does the correct thing for me on Emacs 30.2. That might be a newer default though.
I think on an older version something like this should do it:
(keymap-set completion-list-mode-map "<backtab>" #'previous-completion)
This only works when the completion buffer is selected though (e.g. via completion-auto-select). I'm not really sure how to get useful backtab behavior in the minibuffer itself.
Edit -- These bindings might be worth trying as well if you don't like the auto selection:
(keymap-set minibuffer-local-completion-map "<tab>" #'minibuffer-next-completion)
(keymap-set minibuffer-local-completion-map "<backtab>" #'minibuffer-previous-completion)
So it's possible I just never noticed the message noting minibuffer-next/previous-completion but those are pretty cool.
But I think I was more thinking of tabbing in the opposite direction for minibuffer-complete; the situation I'm most often finding myself with such an abundance of options is when I'm exploring available functions and just looking; I rarely want to go one-by-one in such a scenario.
…but what I just discovered is that functionality is already provided (I was confused when I saw that "backtab" was already assigned in minibuffer-local-completion-map); it just doesn't seem to be there when auto-completing in Eval: (which just responds with "<backtab> is undefined"); which is how I'm most often looking at other available functions. That must be why I thought it never worked.
Welp, I appreciate the info., regardless; I definitely learned a bit more than I knew before. And it's good to know backtab will actually work in M-x, if I ever find I need it.
Maybe M-p?
Not quite (though I hadn't realized, before this thread, that such an option existed); I was more thinking of tabbing in the opposite direction for minibuffer-complete.
I sort of lay out everything in the comment at https://midwest.social/comment/24082938but the short of it is that I realized that minibuffer-complete does have functionality already built it: it just doesn't seem to work when trying to to autocompletion in Eval:. So I didn't realize that it'd work in circumstances like M-x.
Thanks so much for the suggestion, though! 'Appreciate the help.
Thanks for sharing. In this age of slop, I tend to lean towards the built-in packages more and more nowadays.
What https://github.com/jamescherti/minimal-emacs.dhas taught me is that vanilla Emacs is perfectly capable, especially with the built-in support for LSP and Treesitter, if you need them.