reddit / emacs

completion confusion

mmiri-ifuru · 2022-04-11 15:35
Hi, I am trying to wrap my head around completions in emacs. To begin, I am not sure what the definition of 'completion' in the context of emacs is, so I am using the term quite vaguely. It is unfortunate, but is perhaps a good indication of where my emacs knowledge stands right now. I have figured out that packages like `selectrum` and `vertico` shape how minibuffer suggestions appear on the screen. From the `vertico` page, I then moved on to `consult`. My current understanding is that packages like `ivy`/`helm`/`consult` provide enhancements to emacs commands (and perhaps also introduce some new commands) for buffer selection, register selection etc., including algorithms and interfaces for showing sensible possible options for the minibuffer prompt. However, where I totally get lost is `company`. What does `company` do? I am experimenting with `lsp-mode`, and it suggests using `company`. Does `company` also do the same thing as `consult`? Any comments and suggestions like links to pages which explain this ecosystem would be awesome. Thanks!
lebensterben · 2022-04-11 15:41
company provides auto-completion for programming languages.
Illiamen · 2022-04-11 16:52
"Completion" means having Emacs complete a word/filename/function that you started typing. Packages like Vertico and Selectrum are for completion in the minibuffer (e.g., for `find-file`). Packages like Company and Corfu automatically create small pop-up windows for completion while writing in files. For example, LSP can suggest function names while you write, which Company can show in a pop-up window near the cursor. The built-in version of packages like Company is the command `completion-in-region` (`M-TAB` or `C-M-i`), which uses the minibuffer instead of a small pop-up window and is not automatic. Company is an alternative way of using Emacs's (and packages') completion-at-point functions (a.k.a. CAPFs). Consult is a collection of featureful commands meant to be better than some of the built-in commands that come with Emacs. It can be used with several completion interfaces, including Vertico and Emacs's default interface.
mmiri-ifuru · 2022-04-11 18:31
That makes things so much clearer. Thank you for taking the time to write such a detailed explanation. Much appreciated!
pajuch · 2022-04-12 09:00
Someone needs to create a flowchart to portray what is doing what, this confusion really harmed my use of emacs at the beginning.
deltille · 2022-04-12 18:41
'Completion' is used here as a generic term for when emacs gives you an interactive way to pick something from a list (data type). For example, when you hit m-x, that's giving you a 'completion' for a list of all the interactive commands in emacs. So when you have a 'completion framework' or 'completion package' it's usually code that changes how the search is applied (eg. fuzzy search) and how the results are shown. Sometimes they enhance or integrate with other features (eg. helm totally rethinks what 'completion' means and lets it work in the opposite direction), but that's the core of what 'completion' means. Kind of like a specialized subset of 'search'.
mmiri-ifuru · 2022-04-12 18:51
Totally feel you!
oantolin · 2022-04-13 01:04
> helm totally rethinks what 'completion' means and lets it work in the opposite direction What do you mean by "the opposite direction"? I have used Helm but still can't figure out what you mean.
deltille · 2022-04-13 05:33
Helm has facilities for completing to something then deciding to do something else with it (besides your original completion intent).
oantolin · 2022-04-13 05:35
Oh, that! OK. Thanks!
mmiri-ifuru · 2022-04-13 09:01
Thanks! I must admit I have not given helm a go yet. Would you recommend it over something like consult? I have read it is slow, which is why I gave it a miss.
deltille · 2022-04-13 09:14
It depends whether you clearly see it doing something you want for. I used it for a while, but the tradeoff wasn't worth it for me. It was as you've heard slow and buggy in practice, at least for what I was doing. I was drawn to it because I used Quicksilver on mac, but probably not coincidentally, I also never dove too deep into QS' 'compositional' features either.
mmiri-ifuru · 2022-04-14 13:17
Hm. Thanks for the comment. In the interest of time then I'll continue giving helm a miss for now...
bdarcus · 2022-04-14 21:25
E.g. what embark provides.
oantolin · 2022-04-14 21:26
Yep, it's a little ironic and embarrassing that I couldn't figure out what was meant.