branch: master
commit 4d6675879652590c8a6f4c89362840f66c537374
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Allow to toggle matching mode with "C-o m"
* ivy.el (ivy-toggle-fuzzy): New command.
* ivy-hydra.el (hydra-ivy): Bind `ivy-toggle-fuzzy' to "m".
Fixes #142.
---
ivy-hydra.el | 7 +++++--
ivy.el | 8 ++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/ivy-hydra.el b/ivy-hydra.el
index 1efab41..8cfb134 100644
--- a/ivy-hydra.el
+++ b/ivy-hydra.el
@@ -42,13 +42,15 @@
(byte-compile-file (buffer-file-name) t)))
(error "Please install `hydra' and recompile/reinstall
`ivy-hydra'")))))
+
+
(defhydra hydra-ivy (:hint nil
:color pink)
"
^^^^^^ ^Yes^ ^No^ ^Maybe^
^^^^^^^^^^^^^^---------------------------------------
^ ^ _k_ ^ ^ _f_ollow _i_nsert _c_: calling %s(if ivy-calling \"on\"
\"off\")
-_h_ ^✜^ _l_ _d_one _o_ops
+_h_ ^✜^ _l_ _d_one _o_ops _m_: matcher %s(if (eq ivy--regex-function
'ivy--regex-fuzzy) \"fuzzy\" \"ivy\")
^ ^ _j_ ^ ^
"
;; arrows
@@ -61,7 +63,8 @@ _h_ ^✜^ _l_ _d_one _o_ops
("i" nil)
("f" ivy-alt-done :exit nil)
("d" ivy-done :exit t)
- ("c" ivy-toggle-calling))
+ ("c" ivy-toggle-calling)
+ ("m" ivy-toggle-fuzzy))
(provide 'ivy-hydra)
diff --git a/ivy.el b/ivy.el
index 75953bd..aaa7e11 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1366,6 +1366,14 @@ Don't finish completion."
(delete-minibuffer-contents)
(insert ivy--current))
+(defun ivy-toggle-fuzzy ()
+ "Toggle the re builder between `ivy--regex-fuzzy' and `ivy--regex-plus'."
+ (interactive)
+ (setq ivy--old-re nil)
+ (if (eq ivy--regex-function 'ivy--regex-fuzzy)
+ (setq ivy--regex-function 'ivy--regex-plus)
+ (setq ivy--regex-function 'ivy--regex-fuzzy)))
+
(provide 'ivy)
;;; ivy.el ends here