]> code.delx.au - gnu-emacs-elpa/commitdiff
Allow to toggle matching mode with "C-o m"
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 15 Jun 2015 16:26:39 +0000 (18:26 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 15 Jun 2015 16:26:39 +0000 (18:26 +0200)
* ivy.el (ivy-toggle-fuzzy): New command.

* ivy-hydra.el (hydra-ivy): Bind `ivy-toggle-fuzzy' to "m".

Fixes #142.

ivy-hydra.el
ivy.el

index 1efab41c05aa36f809223960b8f9a6e3e27dd945..8cfb134142d190d294b08b01fa914241588506a0 100644 (file)
                (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 75953bdb67a5787bc879e0044b074a3f5c57fa1c..aaa7e11f7fc98fbc6a854923e86f65589e240bf1 100644 (file)
--- 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