From b12faa2988f714d436e3c0687c27c7cf9782fc18 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Fri, 12 Jan 2024 10:21:24 +0100 Subject: [PATCH] ; Adapt some recent changes around completion categories * doc/lispref/minibuf.texi (Completion Variables): * lisp/minibuffer.el (completion-extra-properties) (completion-category-defaults): Mention 'narrow-completions-function'. (completion-category-overrides): Do that, and improve Custom type. --- doc/lispref/minibuf.texi | 3 ++ lisp/minibuffer.el | 78 ++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 2e77f252362..d2cf1ee9215 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -2015,6 +2015,9 @@ The function to add annotations to completions. @item affixation-function The function to add prefixes and suffixes to completions. + +@item narrow-completions-function +Function that reads and returns a completions predicate. @end table @noindent diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7eb68737e64..b948cabdd3d 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1172,6 +1172,7 @@ an association list that can specify properties such as: - `group-function': function for grouping the completion candidates. - `annotation-function': function to add annotations in *Completions*. - `affixation-function': function to prepend/append a prefix/suffix. +- `narrow-completions-function': function to restrict the completions list. Categories are symbols such as `buffer' and `file', used when completing buffer and file names, respectively. @@ -1193,6 +1194,7 @@ possible values are the same as in `completions-sort'. - `group-function': function for grouping the completion candidates. - `annotation-function': function to add annotations in *Completions*. - `affixation-function': function to prepend/append a prefix/suffix. +- `narrow-completions-function': function for narrowing the completions list. See more description of metadata in `completion-metadata'. Categories are symbols such as `buffer' and `file', used when @@ -1201,46 +1203,40 @@ completing buffer and file names, respectively. If a property in a category is specified by this variable, it overrides the default specified in `completion-category-defaults'." :version "25.1" - :type `(alist :key-type (choice :tag "Category" - (const buffer) - (const file) - (const unicode-name) - (const bookmark) - symbol) - :value-type - (set :tag "Properties to override" - (cons :tag "Completion Styles" - (const :tag "Select a style from the menu;" styles) - ,completion--styles-type) - (cons :tag "Completion Cycling" - (const :tag "Select one value from the menu." cycle) - ,completion--cycling-threshold-type) - (cons :tag "Cycle Sorting" - (const :tag "Select one value from the menu." - cycle-sort-function) - (choice (function :tag "Custom function"))) - (cons :tag "Completion Sorting" - (const :tag "Select one value from the menu." - display-sort-function) - (choice (const :tag "Use default" nil) - (const :tag "No sorting" identity) - (const :tag "Alphabetical sorting" - minibuffer-sort-alphabetically) - (const :tag "Historical sorting" - minibuffer-sort-by-history) - (function :tag "Custom function"))) - (cons :tag "Completion Groups" - (const :tag "Select one value from the menu." - group-function) - (choice (function :tag "Custom function"))) - (cons :tag "Completion Annotation" - (const :tag "Select one value from the menu." - annotation-function) - (choice (function :tag "Custom function"))) - (cons :tag "Completion Affixation" - (const :tag "Select one value from the menu." - affixation-function) - (choice (function :tag "Custom function")))))) + :type `(alist + :key-type (choice :tag "Category" + (const buffer) + (const file) + (const unicode-name) + (const bookmark) + symbol) + :value-type (set :tag "Properties to override" + (cons :tag "Completion Styles" + (const styles) ,completion--styles-type) + (cons :tag "Cycling threshold" + (const cycle) + ,completion--cycling-threshold-type) + (cons :tag "Cycle order" + (const cycle-sort-function) function) + (cons :tag "Sorting for display" + (const display-sort-function) + (choice + (const :tag "Default sorting" nil) + (const :tag "No sorting" identity) + (const :tag "Alphabetical" + minibuffer-sort-alphabetically) + (const :tag "Historical" + minibuffer-sort-by-history) + (function :tag "Custom function"))) + (cons :tag "Grouping" + (const group-function) function) + (cons :tag "Annotation" + (const annotation-function) function) + (cons :tag "Affixation" + (const affixation-function) function) + (cons :tag "Restriction" + (const narrow-completions-function) + function)))) (defun completion--category-override (category tag) (or (assq tag (cdr (assq category completion-category-overrides))) @@ -2576,6 +2572,8 @@ These include: `:cycle-sort-function': Function to sort entries when cycling. +`:narrow-completions-function': function for narrowing the completions list. + See more information about these functions above in `completion-metadata'. -- 2.39.2