[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless d1c0cbf87b 137/204: Add matching style and di
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless d1c0cbf87b 137/204: Add matching style and dispatcher per category overrides (fix #31) |
Date: |
Tue, 11 Jan 2022 12:58:24 -0500 (EST) |
branch: externals/orderless
commit d1c0cbf87ba7d927ec64c161ec3aac65b9643b61
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Add matching style and dispatcher per category overrides (fix #31)
---
README.org | 25 +++++++++++++++++++++++++
orderless.el | 54 +++++++++++++++++++++++++++++++++++++++++++-----------
orderless.texi | 24 ++++++++++++++++++++++++
3 files changed, 92 insertions(+), 11 deletions(-)
diff --git a/README.org b/README.org
index b3c912737f..b66786c636 100644
--- a/README.org
+++ b/README.org
@@ -157,6 +157,16 @@ The variable =orderless-matching-styles= can be set to a
list of the
desired matching styles to use. By default it enables the regexp and
initialism styles.
+If you want to use certain matching styles only for completion of
+certain categories, you can add an entry to the built-in variable
+=completion-category-overrides=. For example, to use =orderless-flex= to
+complete buffer names, you could use:
+
+#+begin_src emacs-lisp
+ (add-to-list 'completion-category-overrides
+ '(buffer (orderless-matching-styles orderless-flex)))
+#+end_src
+
*** Style dispatchers
For more fine-grained control on which matching styles to use for
@@ -205,6 +215,21 @@ initialism styles.
without-if-bang))
#+end_src
+As with matching styles, you can set which style dispatchers to use
+for specific completion catgories using the
+=completion-category-overrides= variable. For example, if you wanted to
+match buffer using the =orderless-flex= matching style except for
+components starting with =!=, which you want to treat as excluded terms,
+you could use the following configuration (which relies on the above
+=without-if-bang= dispatcher):
+
+#+begin_src emacs-lisp
+ (add-to-list 'completion-category-overrides
+ '(buffer (orderless-matching-styles orderless-flex)
+ (orderless-style-dispatchers without-if-bang)))
+#+end_src
+
+
** Component separator regexp
The pattern components are space-separated by default: this is
diff --git a/orderless.el b/orderless.el
index d4fe98a1e1..b92e6dd5d4 100644
--- a/orderless.el
+++ b/orderless.el
@@ -415,22 +415,54 @@ DISPATCHERS decline to handle the component, then the
list of
matching STYLES is used. See `orderless-dispatch' for details on
dispatchers.
-The STYLES default to `orderless-matching-styles', and the
-DISPATCHERS default to `orderless-dipatchers'. Since nil gets you
-the default, if want to no dispatchers to be run, use '(ignore)
-as the value of DISPATCHERS.
+If the variable `orderless-transient-component-separator' is
+non-nil, it is used in place of `orderless-component-separator'.
-The `orderless-transient-*' variables, when non-nil, override the
-corresponding value among `orderless-component-separator', STYLES
-and DISPATCHERS.
+When STYLES is nil, it defaults to a list computed as follows:
+
+- if the value of `orderless-transient-matching-styles' is
+ non-nil, this value is used;
+
+- next, the category of the current minibuffer completion session
+ is looked up in `completion-category-overrides' and if the
+ alist associated to it has an `orderless-matching-styles' key,
+ the corresponding value is used;
+
+- otherwise, STYLES defaults to the value of the variable
+ `orderless-matching-styles'.
+
+The analogous process is used if DISPATCHERS is nil. Since nil
+gets you this default, if want to no dispatchers to be run, use
+'(ignore) as the value of DISPATCHERS.
This function is the default for `orderless-pattern-compiler' and
might come in handy as a subroutine to implement other pattern
compilers."
- (unless styles (setq styles orderless-matching-styles))
- (setq styles (or orderless-transient-matching-styles styles))
- (unless dispatchers (setq dispatchers orderless-style-dispatchers))
- (setq dispatchers (or orderless-transient-style-dispatchers dispatchers))
+
+ ;; figure out defaults for styles and dispatchers
+ (let ((overrides
+ (unless (or (not minibuffer-completion-table)
+ (and (or styles orderless-transient-matching-styles)
+ (or dispatchers
orderless-transient-style-dispatchers)))
+ ;; we are in minibuffer completion and at least one out of
+ ;; styles and dispachers might be overridden in
+ ;; completion-category-overrides
+ (let* ((metadata (completion-metadata
+ (buffer-substring-no-properties
+ (field-beginning) (point))
+ minibuffer-completion-table
+ minibuffer-completion-predicate))
+ (category (completion-metadata-get metadata 'category)))
+ (cdr (assq category completion-category-overrides))))))
+ (setq styles (or styles
+ orderless-transient-matching-styles
+ (cdr (assq 'orderless-matching-styles overrides))
+ orderless-matching-styles))
+ (setq dispatchers (or dispatchers
+ orderless-transient-style-dispatchers
+ (cdr (assq 'orderless-style-dispatchers overrides))
+ orderless-style-dispatchers)))
+
(cl-loop
with splitter = (or orderless-transient-component-separator
orderless-component-separator)
diff --git a/orderless.texi b/orderless.texi
index d5361c7ac3..0aa29c6b02 100644
--- a/orderless.texi
+++ b/orderless.texi
@@ -197,6 +197,16 @@ The variable @samp{orderless-matching-styles} can be set
to a list of the
desired matching styles to use. By default it enables the regexp and
initialism styles.
+If you want to use certain matching styles only for completion of
+certain categories, you can add an entry to the built-in variable
+@samp{completion-category-overrides}. For example, to use
@samp{orderless-flex} to
+complete buffer names, you could use:
+
+@lisp
+(add-to-list 'completion-category-overrides
+ '(buffer (orderless-matching-styles orderless-flex)))
+@end lisp
+
@menu
* Style dispatchers::
@end menu
@@ -256,6 +266,20 @@ You can achieve this with the following configuration:
without-if-bang))
@end lisp
+As with matching styles, you can set which style dispatchers to use
+for specific completion catgories using the
+@samp{completion-category-overrides} variable. For example, if you wanted to
+match buffer using the @samp{orderless-flex} matching style except for
+components starting with @samp{!}, which you want to treat as excluded terms,
+you could use the following configuration (which relies on the above
+@samp{without-if-bang} dispatcher):
+
+@lisp
+(add-to-list 'completion-category-overrides
+ '(buffer (orderless-matching-styles orderless-flex)
+ (orderless-style-dispatchers without-if-bang)))
+@end lisp
+
@node Component separator regexp
@section Component separator regexp
- [elpa] externals/orderless a21ef6d985 070/204: If matching-styles is nil, assume regexp matching, (continued)
- [elpa] externals/orderless a21ef6d985 070/204: If matching-styles is nil, assume regexp matching, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 3c4b4815f0 079/204: Refactor strict initialism functions, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless f30a3e912c 082/204: Initial implementation of style dispatchers, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 7e83e37870 086/204: Fine-tune dispatcher semantics, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5897841be4 094/204: Rename default pattern compiler, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 830976770b 102/204: Put integration before related packages in README, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 68e592055c 113/204: The transient variables should not be customizable, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5b292ac136 118/204: Document custom splitter option, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 1d62307cce 125/204: Add badge., ELPA Syncer, 2022/01/11
- [elpa] externals/orderless cbc0109eac 136/204: Merge pull request #28 from b3n/patch-1, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d1c0cbf87b 137/204: Add matching style and dispatcher per category overrides (fix #31),
ELPA Syncer <=
- [elpa] externals/orderless 5dcf4a6f2b 135/204: Corrected broken link, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 701b6a07c8 156/204: orderless-try-completions: Remove _metadata argument, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless a609004d5f 159/204: Document that orderless-regexp matches invalid regexps literally, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d6eb575714 165/204: Merge pull request #44 from minad/invalid-regexp, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 87ab7e47e3 168/204: Merge pull request #46 from minad/remove-pattern-compiler-variable, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d2891b807b 174/204: orderless+initialism example requires Marginalia (see #54), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless e4c38efcd6 176/204: README: Add variable category to orderless+initialism sample, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 871eb1d0f0 178/204: Use add-face-text-property, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless df4f29a4f4 183/204: Use minibuffer customization group, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 62f71c34ba 191/204: Extend prefix optimization to anchored quoted regexps (fix #81), ELPA Syncer, 2022/01/11