Emacs Completion Explained


  • I need intelligent code completion, what to install and how to configure auto-complete/company/ivy/helm?
  • Absolutely no idea how TAB key work.
  • All the windows, [mini]buffers, popups jumping around.
  • Candidates doesn't make sense and comes from unknown sources.

The lack of understanding what happens under the hood makes it hard to debug problems and to work in general.

Minibuffer completion


elisp#Completion Variables

:annotation-function and :affixation-function



icomplete, vertico.el, selectrum, etc.

Not only visual improvements, but also usablity.

Completion Styles

emacs#Completion Styles


elisp#Regular Expressions useful for orderless regexp

  • \s- \SPC
  • ~ = , !


More sources and functionality

consult.el compatible with completing-read API and thus work with default UI, vertico, mct, icomplete, etc.


  • Preview.
  • Grouping.
  • Narrowing.
  • Line numbers.
  • Asyncronous.

Operating on candidates


In-buffer completion or CAP

Ad-hoc commands, which somehow modify text like dabbrev-expand, snippet engines, etc.

elisp#Completion in Buffers completion-at-point-functions, completion-in-region-function.

dabbrev-completion utilize compeltion-in-region.


M-SPC to input space without living completion for orderless completion style.

More sources and functionality


(add-to-list 'completion-at-point-functions 'cape-dabbrev)


Some questions

  • Can minibuffer completion be combined with CAP?
  • Can CAP use minibuffer?
  • Why alternatives exists?
  • Does it make sense to use helm/auto-complete/company/ivy/etc?

Nice to have

  • Filter out component! or rerun on reduced list of candidates.
  • Async CAPFs.


  • The most important thing you need to know about are: in-buffer completion (mostly CAPFs), minibuffer completion and styles.
  • There are tradeoffs between advanced functionality and simple elegant implementation.
  • Most of the features required from completion system can be provided by a list of well-composable simple packages.
  • rde Emacs have almost everything I need preconfigured, and unified to behave consistently.
  • Make love, not war.