cosmicexplorer / helm-rg

ripgrep is nice
GNU General Public License v3.0
101 stars 21 forks source link

Custom preset directory/file groups to search #1

Closed SwiftLawnGnome closed 5 years ago

SwiftLawnGnome commented 6 years ago

This seems possible but I haven't found an easy way to do so. I'd like to be able to make a simple command that will start a helm-rg on both my init file (\~/.emacs.d/init.el) and the directory with all my additional emacs configuration (\~/.emacs.d/lisp/), but not everything else in ~/.emacs.d. If this could easily be accomplished (eg. a function that accepts a list or string of directories/files to rg through) it would be great for creating a hydra with shortcuts to ripgrep through file sets.

cosmicexplorer commented 6 years ago

Hey, thanks for the interest in this project! I was actually just thinking yesterday that it might make sense to have a defcustom for a directory to start searching in, and this seems like a logical extension. I just pushed a few commits which (in part) add a paths argument to the helm-rg interactive function. I think that to get the behavior you want now, you could do something like:

(defun helm-rg-user-emacs-dir ()
  (interactive)
  (let ((helm-rg--paths-to-search '("~/.emacs.d/lisp" "~/.emacs.d/init.el"))
    (call-interactively #'helm-rg)))

Or, if you know the pattern in advance:

(defun helm-rg-user-emacs-dir (pattern)
  (helm-rg pattern nil '("~/.emacs.d/lisp" "~/.emacs.d/init.el")))

These both seem to work for me -- let me know if I'm understanding your use case correctly.