; (completion-preview--try-table): Propagate extra properties.

* lisp/completion-preview.el
(completion-preview--try-table): Let-bind
'completion-extra-properties' to completion properties
that the completion backend (capf) provides, so that these
properties take effect when querying the completion table.
* test/lisp/completion-preview-tests.el
(completion-preview-propagates-properties): Add test.
This commit is contained in:
Eshel Yaron 2025-03-02 08:03:04 +01:00
parent 828e08a996
commit 365a91622e
No known key found for this signature in database
GPG key ID: EF3EE9CA35D78618
2 changed files with 14 additions and 0 deletions

View file

@ -293,6 +293,7 @@ candidates or if there are multiple matching completions and
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(let* ((pred (plist-get props :predicate))
(string (buffer-substring beg end))
(completion-extra-properties props)
(md (completion-metadata string table pred))
(sort-fn (or (completion-metadata-get md 'cycle-sort-function)
(completion-metadata-get md 'display-sort-function)

View file

@ -306,4 +306,17 @@ instead."
(should exit-fn-called)
(should (equal exit-fn-args '("foobar" finished))))))
(ert-deftest completion-preview-propagates-properties ()
"Test the completion metadata handling of Completion Preview mode."
(with-temp-buffer
(setq-local
completion-preview-sort-function #'minibuffer-sort-alphabetically
completion-at-point-functions
(list (completion-preview-tests--capf '("foobaz" "foobar")
:display-sort-function #'identity)))
(insert "foo")
(let ((this-command 'self-insert-command))
(completion-preview--post-command))
(completion-preview-tests--check-preview "baz" 'completion-preview-common)))
;;; completion-preview-tests.el ends here