]> git.eshelyaron.com Git - emacs.git/commitdiff
; (completion-preview--try-table): Propagate extra properties.
authorEshel Yaron <me@eshelyaron.com>
Sun, 2 Mar 2025 07:03:04 +0000 (08:03 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 21:01:04 +0000 (22:01 +0100)
* 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.

(cherry picked from commit 365a91622e093fe0fb74b7fee3ff7cc4a0025611)

lisp/completion-preview.el
test/lisp/completion-preview-tests.el

index dfa6080beb104c9b03e531c43e446079a8e18c33..815879b26b1b19e6f071795f05a3b2ec481a5a59 100644 (file)
@@ -526,6 +526,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)
          (completion-ignore-case completion-preview-ignore-case)
          (md (completion-metadata string table pred))
          (sort-fn (or (completion-metadata-get md 'sort-function)
index e32c53d07c13da25a30d7d25330d6da1541e87e3..ff43c4a85a73238ec800a041c5814ef88cfe3eac 100644 (file)
@@ -440,4 +440,17 @@ instead."
       (completion-preview--post-command))
     (should (not (completion-preview--cursor-modified-p)))))
 
+(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