]> code.delx.au - gnu-emacs-elpa/commitdiff
ivy.el (ivy--regex-fuzzy): Add minibuffer highlighting
authorOleh Krehel <ohwoeowho@gmail.com>
Wed, 30 Sep 2015 13:44:23 +0000 (15:44 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Wed, 30 Sep 2015 13:45:59 +0000 (15:45 +0200)
* ivy-test.el (ivy--regex-fuzzy): Update test.

Re #207

ivy-test.el
ivy.el

index 10dd8f98400516b90c6a55d84c7143bbf38fc34f..76f2ddeb7d6ce62ec6e05c64c805373ab0c785c4 100644 (file)
 
 (ert-deftest ivy--regex-fuzzy ()
   (should (string= (ivy--regex-fuzzy "tmux")
-                   "t.*m.*u.*x"))
+                   "\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)"))
   (should (string= (ivy--regex-fuzzy "^tmux")
-                   "^t.*m.*u.*x"))
+                   "^\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)"))
   (should (string= (ivy--regex-fuzzy "^tmux$")
-                   "^t.*m.*u.*x$"))
+                   "^\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)$"))
   (should (string= (ivy--regex-fuzzy "")
                    ""))
   (should (string= (ivy--regex-fuzzy "^")
                  '("the" "The")))
   (should (equal (ivy--filter "The" '("foo" "the" "The"))
                  '("The"))))
-
diff --git a/ivy.el b/ivy.el
index 0dab956ff2a85abfc03faf12e3d46ab4d22b5294..5f7ed6f9a0e38b06a160ee919de9f8841ba3324d 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1226,9 +1226,14 @@ Everything after \"!\" should not match."
   "Build a regex sequence from STR.
 Insert .* between each char."
   (if (string-match "\\`\\(\\^?\\)\\(.*?\\)\\(\\$?\\)\\'" str)
-      (concat (match-string 1 str)
-              (mapconcat #'string (string-to-list (match-string 2 str)) ".*")
-              (match-string 3 str))
+      (prog1
+          (concat (match-string 1 str)
+                  (mapconcat
+                   (lambda (x)
+                     (format "\\(%c\\)" x))
+                   (string-to-list (match-string 2 str)) ".*")
+                  (match-string 3 str))
+        (setq ivy--subexps (length (match-string 2 str))))
     str))
 
 ;;** Rest