File: completion-preview.el.html

This library provides the Completion Preview mode. This minor mode displays a completion suggestion for the symbol at point in an overlay after point. Check out the customization group completion-preview for user options that you may want to tweak.

To enable Completion Preview mode, use completion-preview-mode(var)/completion-preview-mode(fun). To accept the completion suggestion, press TAB. If you want to ignore a completion suggestion, just go on editing or moving around the buffer. Completion Preview mode continues to update the suggestion as you type according to the text around point.

The commands completion-preview-next-candidate and completion-preview-prev-candidate allow you to cycle the completion candidate that the preview suggests. These commands don't have a default keybinding, but you can bind them, for example, to M-n and M-p in completion-preview-active-mode-map to have them handy whenever the preview is visible.

When the completion candidate that the preview is showing shares a common prefix with all other candidates, Completion Preview mode underlines that common prefix. If you want to insert the common prefix but with a different suffix than the one the preview is showing, use the command completion-preview-complete. This command inserts just the common prefix and lets you go on typing as usual. If you invoke completion-preview-complete when there is no common prefix (so nothing is underlined in the preview), it displays a list of all matching completion candidates.

If you set the user option completion-preview-exact-match-only to non-nil, Completion Preview mode only suggests a completion candidate when its the only possible completion for the (partial) symbol at point. The user option completion-preview-commands says which commands should trigger the completion preview. The user option completion-preview-minimum-symbol-length specifies a minimum number of consecutive characters with word or symbol syntax that should appear around point for Emacs to suggest a completion. By default, this option is set to 3, so Emacs suggests a completion if you type "foo", but typing just "fo" doesn't show the preview. If you want the preview to appear also after non-symbol characters, such as punctuation, set completion-preview-minimum-symbol-length to nil. If you do so, you may want to customize the user option completion-preview-idle-delay to have the preview appear only when you pause typing for a short duration rather than after every key. Try setting it to 0.2 seconds and see how that works for you.

Defined variables (19)

completion-preview--inhibit-update-pWhether to inhibit updating the completion preview following this command.
completion-preview--internal-commandsList of commands that manipulate the completion preview.
completion-preview--mouse-mapKeymap for mouse clicks on the completion preview.
completion-preview--timerIdle timer for updating the completion preview.
completion-preview-active-modeNon-nil if Completion-Preview-Active mode is enabled.
completion-preview-active-mode-hookHook run after entering or leaving ‘completion-preview-active-mode’.
completion-preview-active-mode-mapKeymap for Completion Preview Active mode.
completion-preview-commandsList of commands that should trigger completion preview.
completion-preview-completion-stylesList of completion styles that Completion Preview mode uses.
completion-preview-exact-match-onlyWhether to show completion preview only when there is an exact match.
completion-preview-idle-delayIf non-nil, wait this many idle seconds before displaying completion preview.
completion-preview-message-formatMessage to show after cycling the completion preview suggestion.
completion-preview-minimum-symbol-lengthMinimum length of the symbol at point for showing completion preview.
completion-preview-modeNon-nil if Completion-Preview mode is enabled.
completion-preview-mode-hookHook run after entering or leaving ‘completion-preview-mode’.
completion-preview-sort-functionSort function to use for choosing a completion candidate to preview.
global-completion-preview-modeNon-nil if Global Completion-Preview mode is enabled.
global-completion-preview-mode-hookHook run after entering or leaving ‘global-completion-preview-mode’.
global-completion-preview-modesWhich major modes ‘completion-preview-mode’ is switched on in.

Defined functions (23)

completion-preview--active-p(SYMBOL BUFFER)
completion-preview--capf-wrapper(CAPF)
completion-preview--get(PROP)
completion-preview--ignore()
completion-preview--inhibit-update()
completion-preview--make-overlay(POS STRING)
completion-preview--post-command()
completion-preview--show()
completion-preview--try-table(TABLE BEG END PROPS)
completion-preview--try-update()
completion-preview--update()
completion-preview--update-from-timer(WINDOW BUFFER)
completion-preview--window-selection-change(WINDOW)
completion-preview-active-mode(&optional ARG)
completion-preview-complete()
completion-preview-hide()
completion-preview-insert()
completion-preview-mode(&optional ARG)
completion-preview-next-candidate(N)
completion-preview-prev-candidate(N)
completion-preview-require-certain-commands()
completion-preview-require-minimum-symbol-length()
global-completion-preview-mode(&optional ARG)

Defined faces (4)

completion-previewFace for completion candidates in the completion preview overlay.
completion-preview-commonFace for the longest common prefix in the completion preview.
completion-preview-exactFace for matches in the completion preview overlay.
completion-preview-highlightFace for highlighting the completion preview when the mouse is over it.