Open harold opened 5 years ago
The PR #157 added a functionality similar to what you are looking for. With elisp you can do something like
(ag/search "x" "/home/vitor" :files '("test/a" "test/b"))
-*- mode: ag; default-directory: "~/" -*-
Ag started at Wed Jul 31 20:30:27
ag --literal --group --line-number --column --color --color-match 30\;43 --color-path 1\;32 --smart-case --stats -- x test/a test/b
File: test/a
1:1:x
File: test/b
1:1:x
2 matches
2 files contained matches
2 files searched
2 bytes searched
0.000325 seconds
Ag finished at Wed Jul 31 20:30:27
I hope this helps!
Woah, that's neat! Thanks. I will play with this.
Nice :) . There is also the unmerged pr #158, it tries to add a nice integration with dired. If/once it gets merged you can do something like this gif: https://gist.githubusercontent.com/vitorqb/291b7129effd0f85885fb30cfdcf6ebf/raw/1e18f2fb88c28a7258732319e7b2893f3d17c0a5/img.gif
Ha! That's nuts 🥜.
That's a few too many steps for me. What I think I'd like, and what I may try to do with the new list :files
argument is to have a way of quickly specifying some root search paths (maybe a file in my project's root directory, or maybe just some hardcoded set of search paths) and then to be able to quickly search all those, maybe with a sequence as short as M-x ag-something RET search-string RET
.
Definitely doing it in general involves either a lot of configuration or a lot of steps. I sometimes find myself going out to my terminal and just doing cd ...
, then ag --clojure search-string
. This is quite general and pretty fast, but two obvious downsides (1) the results aren't in an emacs buffer for going between them w/ next-error
and (2) no good way to do excludes if there are lots of siblings in the parent folder.
Regardless, I appreciate your efforts here and hope we all have fun searching for a long time to come.
On my machine, the output of
ag --version
is:My Emacs version is:
I'm using:
From the command line I can do something like:
Searching for
x
in files intest/a
andtest/b
simultaneously.Is this possible in ag.el? Perhaps by some clever use of
ag-project-root-function
?Ultimately I am working on an app, and would like to search the app's code and some of the libraries that the app uses simultaneously.
Thanks in advance for your time and consideration, this package is rad and I use it every day.