diff options
| author | Omar Antolín <omar.antolin@gmail.com> | 2020-04-17 18:38:17 -0500 |
|---|---|---|
| committer | Omar Antolín <omar.antolin@gmail.com> | 2020-04-17 18:38:17 -0500 |
| commit | 92183431712f94b042c6b6caba2b6c2415db3c66 (patch) | |
| tree | e793e4a3ee9996d28c6ea7149f9aea4161374739 | |
| parent | 3b2741737b9e411362e6a8612487da3fe58132ab (diff) | |
Add command to temporarily change separator
| -rw-r--r-- | README.org | 10 | ||||
| -rw-r--r-- | orderless.el | 20 |
2 files changed, 30 insertions, 0 deletions
@@ -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 67f71a7..0d5bbdd 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 |
