Projectile search only part of the project
Asked Answered
R

3

6

When using emacs Projectile and helm-projectile, I am used to search for text inside the whole project. However is there a way to search only part of the project?

Something like:

  • search inside a subfolder only
  • search while excluding a subfolder
Ruella answered 11/10, 2016 at 16:43 Comment(3)
I don't think searching inside a sub-folder is a proper use-case for projectile. Please consider using any generic library/package to do so e.g. silversearcher-ag/silversearcher-ag-elIbeam
@Ibeam could you post a link? ThanksRuella
github.com/ggreer/the_silver_searcher#emacsIbeam
R
3

For now I am using rgrep, which prompts for a string and a directory to find.

I would be happy to hear about an equivalent solution using ag, and I should mention I haven't yet dug into the link from @goromlagche (https://github.com/ggreer/the_silver_searcher#emacs).

Ruella answered 24/10, 2016 at 21:49 Comment(1)
Personally I didn't find ack or ag to be any better or faster than Emacs rgrep in practice. The most useful thing those other tools do is to automatically exclude files and directories that you wouldn't want to search, and rgrep does that too. So while they would be good on the command line, I found I had no reason to integrate them with Emacs.Marbut
H
5

Yes you can exclude (sub) folders. Add a line in your .projectile:

-/sub/folder

So search inside a subfolder, I don't see something automatic. You could put project files in some subfolders (https://projectile.readthedocs.io/en/latest/configuration/#file-local-project-root-definitions) and switch projects.

Hybrid answered 11/10, 2016 at 19:59 Comment(1)
That could be a workaround, however I need this kind of search only sporadically (and the reason I want this kind of search is to move files around in a big project into separate subfolders).Ruella
R
3

For now I am using rgrep, which prompts for a string and a directory to find.

I would be happy to hear about an equivalent solution using ag, and I should mention I haven't yet dug into the link from @goromlagche (https://github.com/ggreer/the_silver_searcher#emacs).

Ruella answered 24/10, 2016 at 21:49 Comment(1)
Personally I didn't find ack or ag to be any better or faster than Emacs rgrep in practice. The most useful thing those other tools do is to automatically exclude files and directories that you wouldn't want to search, and rgrep does that too. So while they would be good on the command line, I found I had no reason to integrate them with Emacs.Marbut
G
2

Install helm-ag, this requires silversearcher-ag package; for debian apt install silversearcher-ag. And then you can

  1. helm-do-ag to search inside a sub-folder/directory inside project
  2. to ignore sub-folders/directories add them to either .gitignore or .hgignore if it is git and hg project respectively or add then to .projectile file, details here.

references:

  1. https://github.com/emacsorphanage/helm-ag
  2. https://github.com/ggreer/the_silver_searcher
Ga answered 21/8, 2020 at 16:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.