pairs. The following properties are supported:
@table @code
+@item :category
+The value should be a symbol describing what kind of text the
+completion function is trying to complete. If the symbol matches one
+of the keys in @code{completion-category-overrides}, the usual
+completion behavior is overridden. @xref{Completion Variables}.
+
@item :annotation-function
The value should be a function to add annotations in the completions
buffer. This function must accept one argument, a completion, and
+++
*** 'completion-extra-properties' supports more metadata.
-The new supported completion properties are 'group-function',
-'display-sort-function', 'cycle-sort-function'.
+The new supported completion properties are 'category',
+'group-function', 'display-sort-function', 'cycle-sort-function'.
** Pcomplete
(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)))
minibuffer-completion-table
minibuffer-completion-predicate))
+(defun completion--metadata-get-1 (metadata prop)
+ (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))))))))
+
(defun completion-metadata-get (metadata prop)
"Get property PROP from completion METADATA.
If the metadata specifies a completion category, the variables
`completion-extra-properties' plist are keyword symbols, not
plain symbols."
(if-let (((not (eq prop 'category)))
- (cat (alist-get 'category metadata))
+ (cat (completion--metadata-get-1 metadata 'category))
(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)))))))))
+ (completion--metadata-get-1 metadata prop)))
(defun complete-with-action (action collection string predicate)
"Perform completion according to ACTION.
"Property list of extra properties of the current completion job.
These include:
+`:category': the kind of objects returned by `all-completions'.
+ Used by `completion-category-overrides'.
+
`:annotation-function': Function to annotate the completions buffer.
The function must accept one argument, a completion string,
and return either nil or a string which is to be displayed