diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-10-23 07:17:46 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-10-23 07:17:46 +0200 |
commit | 1f1ed0a8261971193708b8cfb61a5cb3aa51d20d (patch) | |
tree | 589f14b565114b2c0b92f530b3bca19b4ea21980 /helm-utils.el | |
parent | b390c5f569b9c8b631d75f7087cc2ac70f60be6f (diff) |
Fix highlighting matches with pcre based regexps.
* helm-utils.el (helm--translate-pcre-to-elisp): New.
(helm-highlight-current-line): Use it.
Diffstat (limited to 'helm-utils.el')
-rw-r--r-- | helm-utils.el | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/helm-utils.el b/helm-utils.el index 6c4fba92..7a2d732d 100644 --- a/helm-utils.el +++ b/helm-utils.el @@ -612,7 +612,9 @@ If STRING is non--nil return instead a space separated string." (catch 'empty-line (cl-loop with ov for r in (helm-remove-if-match - "\\`!" (split-string helm-input)) + "\\`!" (split-string + ;; Needed for highlighting AG matches. + (helm--translate-pcre-to-elisp helm-input))) do (save-excursion (goto-char start-match) (while (condition-case _err @@ -630,6 +632,23 @@ If STRING is non--nil return instead a space separated string." (overlay-put ov 'priority 1))))))) (recenter))) +(defun helm--translate-pcre-to-elisp (regexp) + "Should translate pcre REGEXP to elisp regexp. +Return elisp regexp unchanged if REGEXP is an elisp regexp." + (with-temp-buffer + (insert " " regexp " ") + (goto-char (point-min)) + (save-excursion + ;; match (){}| unquoted + (helm-awhile (and (re-search-forward "\\S\\\\([(){}|]\\)" nil t) + (match-string 1)) + (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)) + (replace-match (concat it "-") t t nil 1)) + (buffer-substring (1+ (point-min)) (1- (point-max))))) + (defun helm-match-line-cleanup () (when helm-match-line-overlay (delete-overlay helm-match-line-overlay) |