Emacs Init: Icomplete Mode

By Xah Lee. Date: .

Emacs Init: Icomplete Mode

I recommend just turn on icomplete-vertical-mode and set flex match.

Put this in your Emacs Init File:

(when (>= emacs-major-version 28)
  ;; emacs 28 or later. use icomplete-vertical-mode and set flex match
  (setq completion-styles '(flex))
  (icomplete-vertical-mode 1))

Completion Styles

you can setup many different completion styles.

here are different styles, from Completion Styles (Emacs Manual)

'basic
  • A matching completion alternative must have the same beginning as the text in the minibuffer before point.
  • Furthermore, if there is any text in the minibuffer after point, the rest of the completion alternative must contain that text as a substring.
'partial-completion
  • This aggressive completion style divides the minibuffer text into words separated by hyphens or spaces, and completes each word separately.
  • (e.g. when completing command names, em-l-m completes to emacs-lisp-mode.)
  • Furthermore, a ‘*’ in the minibuffer text is treated as a “wildcard”—it matches any string of characters at the corresponding position in the completion alternative.
'emacs22
  • similar to basic, except that it ignores the text in the minibuffer after point.
'substring
  • A matching completion alternative must contain the text in the minibuffer before point, and the text in the minibuffer after point, as substrings (in that same order).
  • Thus, if the text in the minibuffer is foobar, with point between foo and bar, that matches AfooBbarC, where A, B, and C can be any string including the empty string.
'flex

if you typed abc it is matched against *a*b*c* where * are any char or no char.

'initials

lch matches list-command-history

Setup completion-styles

completion-styles
variable. List of completion styles to use. The available styles are listed in completion-styles-alist .
;; examples of setting completion styles

;; use flex match.
(setq completion-styles '(flex))

;; default in emacs 29
(setq completion-styles '(basic partial-completion emacs22))

Emacs, minibuffer name completion