branch: externals/orderless
commit da876320b3e7ac123c16eaa0f628d00724444597
Author: Omar Antolín <[email protected]>
Commit: Omar Antolín <[email protected]>
Remove all orderless-transient-* variables (fix #34)
---
README.org | 51 +++++++++++++--------------------------------------
orderless.el | 57 ++++-----------------------------------------------------
2 files changed, 17 insertions(+), 91 deletions(-)
diff --git a/README.org b/README.org
index f74c6663cd..03a569a299 100644
--- a/README.org
+++ b/README.org
@@ -254,56 +254,31 @@ lists to use instead of =orderless-matching-styles=.
** Interactively changing the configuration
You might want to change the separator or the matching style
-configuration on the fly while matching. There many possible UIs for
-this: you could toggle between two chosen configurations, cycle among
-several, have a keymap where each key sets a different configurations,
-have a set of named configurations and be prompted (with completion)
-for one of them, popup a [[https://github.com/abo-abo/hydra][hydra]] to choose
a configuration, etc.
-
-Rather than include commands for any of those on-the-fly configuration
-changes, =orderless= provides a general mechanism to make it easy to
-write such commands yourself. For each variable you might to
-temporarily change there is a corresponding /transient/ variable that
-overrides it when the transient variable is non-nil. You can write
-your own commands to set these transient variable to the desired value
-without clobbering the value of the variables they override. To reset
-the transient variables to =nil= again after each completion session,
-use the following configuration:
-
-#+begin_src emacs-lisp
- (add-hook 'minibuffer-exit-hook
- #'orderless-remove-transient-configuration)
-#+end_src
-
-The transient variables provided are:
-
-- =orderless-transient-component-separator=
-- =orderless-transient-matching-styles=
-- =orderless-transient-style-dispatchers=
+configuration on the fly while matching. There many possible user
+interfaces for this: you could toggle between two chosen
+configurations, cycle among several, have a keymap where each key sets
+a different configurations, have a set of named configurations and be
+prompted (with completion) for one of them, popup a
[[https://github.com/abo-abo/hydra][hydra]] to choose a
+configuration, etc. Since there are so many possible UIs and which to
+use is mostly a matter of taste, =orderless= does not provide any such
+commands. But it's easy to write your own!
For example, say you want to use the keybinding =C-l= to make all
-components match literally. You could use the following configuration:
+components match literally. You could use the following code:
#+begin_src emacs-lisp
(defun my/match-components-literally ()
"Components match literally for the rest of the session."
(interactive)
- (setq orderless-transient-matching-styles '(orderless-literal)
- orderless-transient-style-dispatchers '(ignore)))
-
- (add-hook 'minibuffer-exit-hook
- #'orderless-remove-transient-configuration)
+ (setq-local orderless-matching-styles '(orderless-literal)
+ orderless-style-dispatchers nil))
(define-key minibuffer-local-completion-map (kbd "C-l")
#'my/match-components-literally)
#+end_src
-Note that we also set =orderless-transient-style-dispatchers= to
-='(ignore)=, to ensure no style dispatchers are used so the literal
-matching does not get overridden. You may want to allow the
-dispatchers in =orderless-style-dispatchers= to override, in which case
-you'd set =orderless-transient-style-dispatchers= to =nil= or simply
-remove that assignment.
+Using =setq-local= to assign to the configuration variables ensures the
+values are only used for that minibuffer completion session.
* Integration with other completion UIs
diff --git a/orderless.el b/orderless.el
index ab6b0ed1de..e81134fee4 100644
--- a/orderless.el
+++ b/orderless.el
@@ -103,17 +103,6 @@ or a function of a single string argument."
(function : tag "Custom function"))
:group 'orderless)
-(defvar-local orderless-transient-component-separator nil
- "Component separator regexp override.
-This variabel, if non-nil, overrides `orderless-component-separator'.
-It is meant to be set by commands that interactively change the
-separator. No such commands are provided with this package, but
-this variable is meant to make writing them simple. If you do
-use this variable you are likely to want to reset it to nil after
-every completion session, which can be achieved by adding the
-function `orderless-remove-transient-configuration' to the
-`minibuffer-exit-hook'.")
-
(defcustom orderless-match-faces
[orderless-match-face-0
orderless-match-face-1
@@ -167,30 +156,6 @@ information on how this variable is used, see
:type 'hook
:group 'orderless)
-(defvar-local orderless-transient-matching-styles nil
- "Component matching styles override.
-This variable, if non-nil, overrides `orderless-matching-styles'.
-It is meant to be set by commands that interactively change the
-matching style configuration. No such commands are provided with
-this package, but this variable is meant to make writing them
-simple. If you do use this variable you are likely to want to
-reset it to nil after every completion session, which can be
-achieved by adding the function
-`orderless-remove-transient-configuration' to the
-`minibuffer-exit-hook'.")
-
-(defvar-local orderless-transient-style-dispatchers nil
- "Component style dispatchers override.
-This variable, if non-nil, overrides `orderless-style-dispatchers'.
-It is meant to be set by commands that interactively change the
-matching style configuration. No such commands are provided with
-this package, but this variable is meant to make writing them
-simple. If you do use this variable you are likely to want to
-reset it to nil after every completion session, which can be
-achieved by adding the function
-`orderless-remove-transient-configuration' to the
-`minibuffer-exit-hook'.")
-
(defcustom orderless-pattern-compiler #'orderless-default-pattern-compiler
"The `orderless' pattern compiler.
This should be a function that takes an input pattern and returns
@@ -355,12 +320,6 @@ converted to a list of regexps according to the value of
(lambda (piece) (replace-regexp-in-string (string 0) " " piece))
(split-string (replace-regexp-in-string "\\\\ " (string 0) string) " ")))
-(defun orderless-remove-transient-configuration ()
- "Remove all transient orderless configuration.
-Meant to be added to `exit-minibuffer-hook'."
- (setq orderless-transient-matching-styles nil
- orderless-transient-component-separator nil))
-
(defun orderless-dispatch (dispatchers default string &rest args)
"Run DISPATCHERS to compute matching styles for STRING.
@@ -420,23 +379,15 @@ 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.
-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."
(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)
- with components = (if (functionp splitter)
- (funcall splitter pattern)
- (split-string pattern splitter))
+ with components = (if (functionp orderless-component-separator)
+ (funcall orderless-component-separator pattern)
+ (split-string pattern orderless-component-separator))
with total = (length components)
for component in components and index from 0
for (newstyles . newcomp) = (orderless-dispatch
@@ -537,7 +488,7 @@ string for the completion style."
(try-completion (funcall fn-name "-try-completion"))
(all-completions (funcall fn-name "-all-completions"))
(doc-fmt "`%s' function for the %s completion style.
-This configures orderless according to the %s completion style and
+This configures orderless according to the %s completion style and
delegates to `orderless-%s'.")
(fn-doc (lambda (fn) (format doc-fmt fn name name fn))))
`(progn