I am afraid that is not possible at the moment, but you can modify helm-grep--prepare-cmd-line
yourself and have it work. A simple way it to change helm-grep.el#L510-514 from
(exclude (unless (helm-grep-use-ack-p)
(if helm-grep-in-recurse
(concat (or include ignored-files)
" " ignored-dirs)
ignored-files)))
to
(exclude (unless (helm-grep-use-ack-p)
(if helm-grep-in-recurse
(concat include " " ignored-files " " ignored-dirs)
(concat include " " ignored-files))))
By the way, to ignore bad-dir
, you need to use helm-grep-ignored-directories
instead of helm-grep-ignored-files
.
Here is what you can add to your init file to achieve this:
(with-eval-after-load 'helm-grep
(defun my-helm-grep--prepare-cmd-line (only-files &optional include zgrep)
(let* ((default-directory (or helm-ff-default-directory
(helm-default-directory)
default-directory))
(fnargs (helm-grep-prepare-candidates
only-files default-directory))
(ignored-files (unless (helm-grep-use-ack-p)
(mapconcat
(lambda (x)
(concat "--exclude="
(shell-quote-argument x)))
helm-grep-ignored-files " ")))
(ignored-dirs (unless (helm-grep-use-ack-p)
(mapconcat
;; Need grep version >=2.5.4
;; of Gnuwin32 on windoze.
(lambda (x)
(concat "--exclude-dir="
(shell-quote-argument x)))
helm-grep-ignored-directories " ")))
(exclude (unless (helm-grep-use-ack-p)
(if helm-grep-in-recurse
(concat include " " ignored-files " " ignored-dirs)
(concat include " " ignored-files))))
(types (and (helm-grep-use-ack-p)
;; When %e format spec is not specified
;; in `helm-grep-default-command'
;; we need to pass an empty string
;; to types to avoid error.
(or include "")))
(smartcase (if (helm-grep-use-ack-p)
""
(unless (let ((case-fold-search nil))
(string-match-p
"[[:upper:]]" helm-pattern))
"i")))
(helm-grep-default-command
(concat helm-grep-default-command " %m")) ; `%m' like multi.
(patterns (helm-mm-split-pattern helm-pattern t))
(pipe-switches (mapconcat 'identity helm-grep-pipe-cmd-switches " "))
(pipes
(helm-aif (cdr patterns)
(cl-loop with pipcom = (helm-grep--pipe-command-for-grep-command
smartcase pipe-switches)
for p in it concat
(format " | %s %s" pipcom (shell-quote-argument p)))
"")))
(format-spec
helm-grep-default-command
(delq nil
(list (unless zgrep
(if types
(cons ?e types)
(cons ?e exclude)))
(cons ?c (or smartcase ""))
(cons ?p (shell-quote-argument (car patterns)))
(cons ?f fnargs)
(cons ?m pipes))))))
(advice-add 'helm-grep--prepare-cmd-line :override #'my-helm-grep--prepare-cmd-line))