]> git.eshelyaron.com Git - emacs.git/commit
New command 'completion-preview-complete'
authorEshel Yaron <me@eshelyaron.com>
Fri, 12 Apr 2024 20:41:10 +0000 (22:41 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 14 Apr 2024 13:57:12 +0000 (15:57 +0200)
commitec9434d34f6eb390fef519cf185c6d9e55397f70
treef8111dbed62fd81ca4e8f410b43abe5712c9d3d5
parentc10fbb4e990226431784d23000fcbbe569c30564
New command 'completion-preview-complete'

This command completes the symbol at point up to the longest
common prefix of all completions candidates.  We also add an
indication of the longest common prefix in the completion
preview by highlighting that part of the preview with the
'completion-preview-exact' face.  To facilitate these features
we change the way we store the completion candidates while the
preview is visible, to explicitly keep the common prefix along
with a list of its suffixes.

* lisp/completion-preview.el (completion-preview--try-table):
Return longest common prefix and list of suffixes instead of
list of full candidates.  Add illustrative comment.
(completion-preview--capf-wrapper, completion-preview--update)
(completion-preview--show, completion-preview-insert)
(completion-preview-next-candidate): Adjust.
(completion-preview-common): New face.
(completion-preview-exact): Tweak to distinguish it from
'completion-preview-common'.
(completion-preview-complete): New command.
(completion-preview-active-mode-map): Bind it.
(completion-preview-mode): Mention it in docstring.
(completion-preview-commands): Add 'completion-preview-complete'.
(completion-preview--make-overlay): Simplify.
(completion-preview--internal-command-p): Remove.
(completion-preview-require-certain-commands): Update.
(completion-preview--inhibit-update): New inline function.
(completion-preview--inhibit-update-p): New local variable.
(completion-preview--post-command, completion-preview-hide):
Reset it to nil.

* test/lisp/completion-preview-tests.el
(completion-preview-tests--check-preview): Check the 'face'
property of both the first and last character.  Update callers.
(completion-preview-insert-calls-exit-function)
(completion-preview-complete): New tests.
lisp/completion-preview.el
test/lisp/completion-preview-tests.el