bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45234: Annotation function vs. Affixation function


From: Juri Linkov
Subject: bug#45234: Annotation function vs. Affixation function
Date: Tue, 15 Dec 2020 22:19:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> The doc says it receives a list of completions so I think currently  you
> would have to look at the code to figure that out. Maybe we could avoid
> that complication? Currently it seems every affixation would need to check
> if it got a list of strings or a list of items as returned by a possibly
> defined annotation function.

I agree.  So this could be changed like this:

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 456193d52e..404b1236b1 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -123,7 +123,8 @@ completion-metadata
 - `affixation-function': function to prepend/append a prefix/suffix to
    entries.  Takes one argument (COMPLETIONS) and should return a list
    of completions with a list of three elements: completion, its prefix
-   and suffix.
+   and suffix.  This function takes precedence over `annotation-function'
+   when both are provided, so only this function is used.
 - `display-sort-function': function to sort entries in *Completions*.
    Takes one argument (COMPLETIONS) and should return a new list
    of completions.  Can operate destructively.
@@ -1926,6 +1927,8 @@ completion-extra-properties
    completions.  The function must accept one argument, a list of
    completions, and return a list where each element is a list of
    three elements: a completion, a prefix and a suffix.
+   This function takes precedence over `:annotation-function'
+   when both are provided, so only this function is used.
 
 `:exit-function': Function to run after completion is performed.
 
@@ -2056,15 +2059,16 @@ minibuffer-completion-help
                               (if sort-fun
                                   (funcall sort-fun completions)
                                 (sort completions 'string-lessp))))
-                      (when ann-fun
+                      (cond
+                       (aff-fun
+                        (setq completions
+                              (funcall aff-fun completions)))
+                       (ann-fun
                         (setq completions
                               (mapcar (lambda (s)
                                         (let ((ann (funcall ann-fun s)))
                                           (if ann (list s ann) s)))
-                                      completions)))
-                      (when aff-fun
-                        (setq completions
-                              (funcall aff-fun completions)))
+                                      completions))))
 
                       (with-current-buffer standard-output
                         (setq-local completion-base-position

reply via email to

[Prev in Thread] Current Thread [Next in Thread]