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

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

bug#68214: Completion sorting customization by category


From: Daniel Mendler
Subject: bug#68214: Completion sorting customization by category
Date: Sun, 07 Jan 2024 19:37:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Juri Linkov <juri@linkov.net> writes:

> Thanks for the suggestion.  Now pushed in commit 18de131222e,
> so all metadata properties are supported now in
> `completion-category-overrides'.

Thanks.

> What do you think about doing the same for
> `completion-extra-properties'?

Yes, makes sense. The documentation of `completion-extra-properties'
would have to be extended accordingly, mentioning all the newly
supported properties. It bothers me a little bit that the
`completion-metadata-get' lookup wouldn't be allocation-free anymore
(because of keywords versus plain symbols), but one could cache the
keyword symbol.

(defun completion-metadata-get (metadata prop)
  "Get property PROP from completion METADATA.
If the metadata specifies a completion category, the variables
`completion-category-overrides' and
`completion-category-defaults' take precedence for
category-specific overrides.  If the completion metadata does not
specify the property, the `completion-extra-properties' plist is
consulted.  Note that the keys of the
`completion-extra-properties' plist are keyword symbols, not
plain symbols."
  (if-let (((not (eq prop 'category)))
           (cat (alist-get 'category metadata))
           (over (completion--category-override cat prop)))
      (cdr over)
    (or (alist-get prop metadata)
        (plist-get completion-extra-properties
                   ;; Cache the keyword
                   (or (get prop 'completion-extra-properties--keyword)
                       (put prop 'completion-extra-properties--keyword
                            (intern (concat ":" (symbol-name prop)))))))))

Daniel





reply via email to

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