[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#68214: Completion sorting customization by category
From: |
Juri Linkov |
Subject: |
bug#68214: Completion sorting customization by category |
Date: |
Tue, 09 Jan 2024 19:59:13 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
>> 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)))))))))
Thanks, this is now pushed as well in the commit aff1d53cd46.
Now I tried to use a more user-friendly let-binding of
'completion-extra-properties' like below, but then discovered
that it doesn't work for the category.
Maybe 'completion-metadata-get' could try to get a category
from 'completion-extra-properties' as well?
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index e01d5d792a6..2c3e7d28301 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -2337,14 +2337,12 @@ calendar-read-date
(defmon (aref month-array (1- (calendar-extract-month default-date))))
(completion-ignore-case t)
(month (cdr (assoc-string
- (completing-read
- (format-prompt "Month name" defmon)
- (lambda (string pred action)
- (if (eq action 'metadata)
- '(metadata (category . calendar-month))
- (complete-with-action
- action (append month-array nil) string pred)))
- nil t nil nil defmon)
+ (let ((completion-extra-properties
+ '(:category calendar-month)))
+ (completing-read
+ (format-prompt "Month name" defmon)
+ (append month-array nil)
+ nil t nil nil defmon))
(calendar-make-alist month-array 1) t)))
(defday (calendar-extract-day default-date))
(last (calendar-last-day-of-month month year)))
- bug#68214: Completion sorting customization by category, (continued)
- bug#68214: Completion sorting customization by category, Daniel Mendler, 2024/01/03
- bug#68214: Completion sorting customization by category, Juri Linkov, 2024/01/03
- bug#68214: Completion sorting customization by category, Daniel Mendler, 2024/01/03
- bug#68214: Completion sorting customization by category, Juri Linkov, 2024/01/04
- bug#68214: Completion sorting customization by category, Juri Linkov, 2024/01/05
- bug#68214: Completion sorting customization by category, Daniel Mendler, 2024/01/05
- bug#68214: Completion sorting customization by category, Juri Linkov, 2024/01/06
- bug#68214: Completion sorting customization by category, Daniel Mendler, 2024/01/06
- bug#68214: Completion sorting customization by category, Juri Linkov, 2024/01/07
- bug#68214: Completion sorting customization by category, Daniel Mendler, 2024/01/07
- bug#68214: Completion sorting customization by category,
Juri Linkov <=
- bug#68214: Completion sorting customization by category, Juri Linkov, 2024/01/09
- bug#68214: Completion sorting customization by category, Daniel Mendler, 2024/01/09
- bug#68214: Completion sorting customization by category, Juri Linkov, 2024/01/10
- bug#68214: Completion sorting customization by category, Daniel Mendler, 2024/01/10