Skip to content

Commit

Permalink
Return empty string on invalid regexp (grep).
Browse files Browse the repository at this point in the history
* helm-grep.el (helm-grep-init): Bind err, will use it maybe later,
use with-helm-buffer.
(helm-grep--filter-candidate-1): Return empty string on invalid regexp or no match.
  • Loading branch information
thierryvolpiatto committed Sep 30, 2015
1 parent 7c35351 commit 3c0f378
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions helm-grep.el
Expand Up @@ -423,16 +423,17 @@ It is intended to use as a let-bound variable, DON'T set this globaly.")
(set-process-sentinel
(get-buffer-process helm-buffer)
(lambda (process event)
(let ((noresult (= (process-exit-status process) 1)))
(unless noresult
(let* ((err (process-exit-status process))
(noresult (= err 1)))
(unless err
(helm-process-deferred-sentinel-hook
process event (helm-default-directory)))
(cond ((and noresult
;; [FIXME] This is a workaround for zgrep
;; that exit with code 1
;; after a certain amount of results.
(not (with-helm-buffer helm-grep-use-zgrep)))
(with-current-buffer helm-buffer
(with-helm-buffer
(insert (concat "* Exit with code 1, no result found,"
" Command line was:\n\n "
(propertize helm-grep-last-cmd-line
Expand Down Expand Up @@ -984,15 +985,16 @@ in recurse, and ignoring EXTS, search being made on
(car-safe split)))
(lineno (nth 1 split))
(str (nth 2 split)))
(when (and fname lineno str)
(cons (concat (propertize (file-name-nondirectory fname)
'face 'helm-grep-file
'help-echo fname)
":"
(propertize lineno 'face 'helm-grep-lineno)
":"
(if ansi-p str (helm-grep-highlight-match str)))
line))))
(if (and fname lineno str)
(cons (concat (propertize (file-name-nondirectory fname)
'face 'helm-grep-file
'help-echo fname)
":"
(propertize lineno 'face 'helm-grep-lineno)
":"
(if ansi-p str (helm-grep-highlight-match str)))
line)
"")))

(defun helm-grep-filter-one-by-one (candidate)
"`filter-one-by-one' transformer function for `helm-do-grep'."
Expand Down

0 comments on commit 3c0f378

Please sign in to comment.