Function: completion-preview-mode

completion-preview-mode is an autoloaded, interactive and byte-compiled function defined in completion-preview.el.gz.

Signature

(completion-preview-mode &optional ARG)

Documentation

Show in-buffer completion suggestions in a preview as you type.

This mode automatically shows and updates the completion preview according to the text around point. When the preview is visible, TAB (completion-preview-insert) accepts the completion suggestion, M-i (completion-preview-complete) completes up to the longest common prefix of all completion candidates, M-x completion-preview-next-candidate (completion-preview-next-candidate) cycles forward to the next completion suggestion, and M-x completion-preview-prev-candidate (completion-preview-prev-candidate) cycles backward.

This is a minor mode. If called interactively, toggle the Completion-Preview mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate the variable completion-preview-mode(var)/completion-preview-mode(fun).

The mode's hook is called both when the mode is enabled and when it is disabled.

View in manual

Probably introduced at or before Emacs version 30.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/completion-preview.el.gz
;;;###autoload
(define-minor-mode completion-preview-mode
  "Show in-buffer completion suggestions in a preview as you type.

This mode automatically shows and updates the completion preview
according to the text around point.
\\<completion-preview-active-mode-map>\
When the preview is visible, \\[completion-preview-insert] accepts the
completion suggestion, \\[completion-preview-complete] completes up to
the longest common prefix of all completion candidates,
\\[completion-preview-next-candidate] cycles forward to the next
completion suggestion, and \\[completion-preview-prev-candidate] cycles
backward."
  :lighter " CP"
  (if completion-preview-mode
      (add-hook 'post-command-hook #'completion-preview--post-command nil t)
    (remove-hook 'post-command-hook #'completion-preview--post-command t)
    (when completion-preview-active-mode (completion-preview-active-mode -1))
    (when (timerp completion-preview--timer)
      (cancel-timer completion-preview--timer)
      (setq completion-preview--timer nil))))