[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6777cf8 220/272: counsel.el (counsel-unquote-regex-parens)
From: |
Oleh Krehel |
Subject: |
[elpa] master 6777cf8 220/272: counsel.el (counsel-unquote-regex-parens): Improve |
Date: |
Mon, 25 Apr 2016 10:13:26 +0000 |
branch: master
commit 6777cf85866ccbc475453bb9a216878d49576a76
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-unquote-regex-parens): Improve
* counsel.el (counsel-grep-function): Use different quoting. Now it's
possible to use e.g. "(defun foo" as input.
(counsel-unquote-regex-parens): Does the proper unquote now - 4
replacements instead of previous 2.
* ivy-test.el (counsel-unquote-regex-parens): Add test.
---
counsel.el | 26 ++++++++++++++++++++------
ivy-test.el | 5 ++++-
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/counsel.el b/counsel.el
index 31b0ba0..f4d9df6 100644
--- a/counsel.el
+++ b/counsel.el
@@ -42,11 +42,25 @@
(format "%d chars more" (- n (length ivy-text)))))
(defun counsel-unquote-regex-parens (str)
- (replace-regexp-in-string
- "\\\\)" ")"
- (replace-regexp-in-string
- "\\\\(" "("
- str)))
+ (let ((start 0)
+ ms)
+ (while (setq start (string-match "\\\\)\\|\\\\(\\|[()]" str start))
+ (setq ms (match-string-no-properties 0 str))
+ (cond ((equal ms "\\(")
+ (setq str (replace-match "(" nil t str))
+ (setq start (+ start 1)))
+ ((equal ms "\\)")
+ (setq str (replace-match ")" nil t str))
+ (setq start (+ start 1)))
+ ((equal ms "(")
+ (setq str (replace-match "\\(" nil t str))
+ (setq start (+ start 2)))
+ ((equal ms ")")
+ (setq str (replace-match "\\)" nil t str))
+ (setq start (+ start 2)))
+ (t
+ (error "unexpected"))))
+ str))
(defun counsel-directory-parent (dir)
"Return the directory parent of directory DIR."
@@ -1359,7 +1373,7 @@ This uses `counsel-ag' with `counsel-pt-base-command'
replacing
(setq ivy--old-re
(ivy--regex string)))))
(counsel--async-command
- (format "grep -nP --ignore-case '%s' %s" regex counsel--git-grep-dir))
+ (format "grep -nE --ignore-case \"%s\" %s" regex counsel--git-grep-dir))
nil)))
(defun counsel-grep-action (x)
diff --git a/ivy-test.el b/ivy-test.el
index 7533169..866eaa7 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -170,4 +170,7 @@
(ert-deftest counsel-unquote-regex-parens ()
(should (equal (counsel-unquote-regex-parens
(ivy--regex "foo bar"))
- "(foo).*?(bar)")))
+ "(foo).*?(bar)"))
+ (should (equal (counsel-unquote-regex-parens
+ (ivy--regex "(foo bar"))
+ "(\\(foo).*?(bar)")))
- [elpa] master 2bd092d 222/272: ivy.el (ivy--minibuffer-setup): Ensure inhibit-field-text-motion is nil, (continued)
- [elpa] master 2bd092d 222/272: ivy.el (ivy--minibuffer-setup): Ensure inhibit-field-text-motion is nil, Oleh Krehel, 2016/04/25
- [elpa] master 2ac1d2d 256/272: ivy.el (ivy-occur-press): Set counsel-grep-last-line to nil, Oleh Krehel, 2016/04/25
- [elpa] master 4ebf0b4 215/272: ivy.el: Add `counsel-find-file' transformer., Oleh Krehel, 2016/04/25
- [elpa] master 615dd90 241/272: counsel.el (counsel-grep-action): Work better from ivy-occur, Oleh Krehel, 2016/04/25
- [elpa] master 1485e58 076/272: Add ignore pattern toggling, Oleh Krehel, 2016/04/25
- [elpa] master 8dfff3e 200/272: ivy.el (ivy-next-history-element): Improve, Oleh Krehel, 2016/04/25
- [elpa] master 3177419 216/272: ivy.el (ivy-sort-functions-alist): Update :type, Oleh Krehel, 2016/04/25
- [elpa] master abf880f 214/272: ivy.el (ivy-read): Make "M-o" not modify the action, Oleh Krehel, 2016/04/25
- [elpa] master 3f4f080 226/272: counsel-ag now works with ivy-occur-revert-buffer, Oleh Krehel, 2016/04/25
- [elpa] master f31ab12 066/272: swiper.el (swiper--ivy): Return point, Oleh Krehel, 2016/04/25
- [elpa] master 6777cf8 220/272: counsel.el (counsel-unquote-regex-parens): Improve,
Oleh Krehel <=
- [elpa] master ddc1d9f 114/272: Move all faces to ivy-faces group, Oleh Krehel, 2016/04/25
- [elpa] master e92d282 195/272: Make ivy-ignore-buffers similar to ido-ignore-buffers., Oleh Krehel, 2016/04/25
- [elpa] master 4235ffc 092/272: colir.el (colir-blend-face-background): Improve, Oleh Krehel, 2016/04/25
- [elpa] master 9aee83a 105/272: ivy.el (ivy-completion-in-region): Bind completion-ignore-case, Oleh Krehel, 2016/04/25
- [elpa] master 2a1ef54 148/272: ivy-dispatching-done should not permanently modify default action index, Oleh Krehel, 2016/04/25
- [elpa] master 5eaf787 078/272: doc/ivy.org: Improve the Texinfo/HTML export structure, Oleh Krehel, 2016/04/25
- [elpa] master b7c40d3 152/272: ivy.el (ivy-resume): Add a guard against null :action, Oleh Krehel, 2016/04/25
- [elpa] master 2ab9c54 197/272: ivy.el (ivy--switch-buffer-matcher): Fix, Oleh Krehel, 2016/04/25
- [elpa] master db00518 270/272: Bump version to 0.8.0, Oleh Krehel, 2016/04/25
- [elpa] master 96828c2 100/272: ivy.el (ivy-read): Identify extra-actions by caller as well, Oleh Krehel, 2016/04/25