branch: externals/orderless
commit 92183431712f94b042c6b6caba2b6c2415db3c66
Author: Omar Antolín <[email protected]>
Commit: Omar Antolín <[email protected]>
Add command to temporarily change separator
---
README.org | 10 ++++++++++
orderless.el | 20 ++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/README.org b/README.org
index f60df15765..758a3a62fb 100644
--- a/README.org
+++ b/README.org
@@ -33,6 +33,16 @@ If you are implementing a command for which you know you
want a
different separator for the components, bind
=orderless-regexp-separator= in a =let= form.
+The package also provides a command
+=orderless-temporarily-change-separator= to change it for the rest of
+the current completion session. If you want to use it, bind it to a
+key in a keymap that will be active during your completion session:
+
+- Icomplete users should bind it in =icomplete-minibuffer-map=.
+- Users of the default completion should bind it in both
+ =minibuffer-local-completion-map= and
+ =minibuffer-local-filename-completion-map=.
+
** Faces for component matches
The portions of a candidate matching each component get highlighted in
diff --git a/orderless.el b/orderless.el
index 67f71a7e16..0d5bbddd94 100644
--- a/orderless.el
+++ b/orderless.el
@@ -159,5 +159,25 @@ This function is part of the `orderless' completion style."
completion-styles-alist
:test #'equal)
+(defvar orderless-old-regexp-separator nil
+ "Stores the old value of `orderless-regexp-separator'.")
+
+(defun orderless--restore-regexp-separator ()
+ "Restore old value of `orderless-regexp-separator'."
+ (when orderless-old-regexp-separator
+ (setq orderless-regexp-separator orderless-old-regexp-separator
+ orderless-old-regexp-separator nil))
+ (remove-hook 'minibuffer-exit-hook #'orderless--restore-regexp-separator))
+
+(defun orderless-temporarily-change-separator (separator)
+ "Change `orderless-regexp-separator' for the current completion session."
+ (interactive
+ (list (let ((enable-recursive-minibuffers t))
+ (read-string "Orderless regexp separator: "))))
+ (unless orderless-old-regexp-separator
+ (setq orderless-old-regexp-separator orderless-regexp-separator))
+ (setq orderless-regexp-separator separator)
+ (add-to-list 'minibuffer-exit-hook #'orderless--restore-regexp-separator))
+
(provide 'orderless)
;;; orderless.el ends here