summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helm-grep.el1
-rw-r--r--helm-utils.el14
2 files changed, 11 insertions, 4 deletions
diff --git a/helm-grep.el b/helm-grep.el
index ac5df974..64268011 100644
--- a/helm-grep.el
+++ b/helm-grep.el
@@ -1413,6 +1413,7 @@ if available with current AG version."
(defclass helm-grep-ag-class (helm-source-async)
((nohighlight :initform t)
+ (pcre :initform t)
(keymap :initform helm-grep-map)
(help-message :initform 'helm-grep-help-message)
(filter-one-by-one :initform 'helm-grep-filter-one-by-one)
diff --git a/helm-utils.el b/helm-utils.el
index 7a2d732d..cec72b4a 100644
--- a/helm-utils.el
+++ b/helm-utils.el
@@ -614,7 +614,10 @@ If STRING is non--nil return instead a space separated string."
for r in (helm-remove-if-match
"\\`!" (split-string
;; Needed for highlighting AG matches.
- (helm--translate-pcre-to-elisp helm-input)))
+ (if (with-helm-buffer
+ (assq 'pcre (helm-get-current-source)))
+ (helm--translate-pcre-to-elisp helm-input)
+ helm-input)))
do (save-excursion
(goto-char start-match)
(while (condition-case _err
@@ -634,15 +637,18 @@ If STRING is non--nil return instead a space separated string."
(defun helm--translate-pcre-to-elisp (regexp)
"Should translate pcre REGEXP to elisp regexp.
-Return elisp regexp unchanged if REGEXP is an elisp regexp."
+Assume regexp is a pcre based regexp."
(with-temp-buffer
(insert " " regexp " ")
(goto-char (point-min))
(save-excursion
;; match (){}| unquoted
- (helm-awhile (and (re-search-forward "\\S\\\\([(){}|]\\)" nil t)
+ (helm-awhile (and (re-search-forward "\\([(){}|]\\)" nil t)
(match-string 1))
- (replace-match (concat "\\" it) t t nil 1)))
+ (let ((pos (match-beginning 1)))
+ (if (eql (char-before pos) ?\\)
+ (delete-region pos (1- pos))
+ (replace-match (concat "\\" it) t t nil 1)))))
;; match \s or \S
(helm-awhile (and (re-search-forward "\\S\\?\\(\\s\\[sS]\\)[^-]" nil t)
(match-string 1))