2

I've currently got a custom function that I use to grep through files in helm.

;; Search for the thing that the cursor is on or that's already hilighted. If there's nothing,
;; switch back to searching for text interactively.
(defun search-for-region-or-word()
  "Uses helm to search for the currently marked region, or the word under the cursor."
  (interactive)
  (require 'helm-files)  

  (let ((search-text nil))

    ;; If the region isn't active, activated it by selecting the word under the cursor.
    (if (not (region-active-p))
        (setq search-text (thing-at-point 'word 1))
      (setq search-text (buffer-substring-no-properties (region-beginning) (region-end)))
      )

    (deactivate-mark)

    (if (not (string= search-text ""))
        (helm-do-grep-1 (list "e:/path/to-files/") '(4) nil '("*.cpp" "*.h" "*.foop" "*.moo") nil search-text)
      (project-search)
      )
    )
  )

I'd like to keep using helm-do-grep-1, but I'd like to use sift or ag instead of grep. helm-do-ag doesn't seem to have support for feeding it arguments like the search text non-interactively.

I've tried swapping the other search methods in, but all I ever end up with is a blank search that never terminates on its own, so I suspect that I'm giving helm-grep output in a way that it can't parse properly. (Alternately, I'd take advice on how to make helm-do-ag do what I want. It's not a very well documented extension, unfortunately, and I don't really want to pick apart the elisp myself. :P)

Edit: Here's the grep command:

grep -a -d recurse %e -n%cH -e %p %f  

Here's what I'm trying for the sift command:

sift -ars --line-numbers --nogroup --stats -e %p -f %f  

I've also tried:

sift -ars --line-numbers --nogroup --stats %s %s (this works in helm-do-ag)
RealityMonster
  • 261
  • 1
  • 10

0 Answers0