From ea752ba6e3ddf0490f7d3b8ec0f27e08344e0758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Antol=C3=ADn?= Date: Wed, 20 Jan 2021 09:08:35 -0600 Subject: Revert "Add matching style and dispatcher per category overrides (fix #31)" This reverts commit d1c0cbf87ba7d927ec64c161ec3aac65b9643b61. --- README.org | 25 ------------------------- orderless.el | 54 +++++++++++------------------------------------------- orderless.texi | 24 ------------------------ 3 files changed, 11 insertions(+), 92 deletions(-) diff --git a/README.org b/README.org index 847b041..f74c666 100644 --- a/README.org +++ b/README.org @@ -157,16 +157,6 @@ 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 @@ -215,21 +205,6 @@ complete buffer names, you could use: 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 b92e6dd..d4fe98a 100644 --- a/orderless.el +++ b/orderless.el @@ -415,54 +415,22 @@ DISPATCHERS decline to handle the component, then the list of matching STYLES is used. See `orderless-dispatch' for details on dispatchers. -If the variable `orderless-transient-component-separator' is -non-nil, it is used in place of `orderless-component-separator'. +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. -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. +The `orderless-transient-*' variables, when non-nil, override the +corresponding value among `orderless-component-separator', STYLES +and DISPATCHERS. This function is the default for `orderless-pattern-compiler' and might come in handy as a subroutine to implement other pattern compilers." - - ;; 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))) - + (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)) (cl-loop with splitter = (or orderless-transient-component-separator orderless-component-separator) diff --git a/orderless.texi b/orderless.texi index 0aa29c6..d5361c7 100644 --- a/orderless.texi +++ b/orderless.texi @@ -197,16 +197,6 @@ 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 @@ -266,20 +256,6 @@ 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 -- cgit v1.0