emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] `affixation-function`: Allow only three-element lists


From: Juri Linkov
Subject: Re: [PATCH] `affixation-function`: Allow only three-element lists
Date: Sun, 25 Apr 2021 20:46:08 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> @@ -2110,7 +2110,9 @@ minibuffer-completion-help
>                        (cond
>                         (aff-fun
>                          (setq completions
> -                              (funcall aff-fun completions)))
> +                              (funcall aff-fun completions))
> +                        (cl-assert (or (not completions)
> +                                       (= 3 (length (car completions))))))

It's surprising to see that you added such artificial restriction.
I expected a change with something more like this:

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index e435d0124a..324a171e66 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2129,7 +2129,7 @@ minibuffer-completion-help
                         (setq completions
                               (mapcar (lambda (s)
                                         (let ((ann (funcall ann-fun s)))
-                                          (if ann (list s ann) s)))
+                                          (if ann (list s "" ann) s)))
                                       completions))))

and then simplify the implementation of completion--insert-strings
by removing all complexity that handled suffix-only completion strings.

> diff --git a/lisp/simple.el b/lisp/simple.el
> index 999755a642..26eb8cad7f 100644
> --- a/lisp/simple.el
> +++ b/lisp/simple.el
> @@ -2080,8 +2080,11 @@ read-extended-command--affixation
>                              (obsolete
>                               (format " (%s)" (car obsolete)))
>                              ((and binding (not (stringp binding)))
> -                             (format " (%s)" (key-description binding))))))
> -         (if suffix (list command-name suffix) command-name)))
> +                             (format " (%s)" (key-description binding)))
> +                            (t ""))))
> +         (put-text-property 0 (length suffix)
> +                            'face 'completions-annotations suffix)
> +         (list command-name "" suffix)))
>       command-names)))

Why such change only for one particular use of annotations?
Shouldn't completion--insert-strings check if the suffix is an
empty string, and then put the 'completions-annotations' face on it?



reply via email to

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