4

I recently found Projectile and I am loving it. I really like the ivy/counsel integration as well. One thing is missing though:

I am working on a huge project of hundreds of files. This is stored in one big massive Git repository which projectile recognizes as the root of the project. I'd like to keep it recognizing this as the root, as there are some dependencies across the various folders.

How can I run projectile search (e.g. C-c p s r for using ripgrep) and limit results to a specific sub-directory in that project?

Update 2020-06-17

I just found the --iglob option for ripgrep. I'll keep looking for a way to use this along with counsel-projectile-rg, but if anyone knows I'd love to hear an answer!

Ashton Wiersdorf
  • 349
  • 1
  • 11
  • hundreds == "Huge" ;-) I just counted the number of files in our project: 68921. – Tobias Feb 27 '20 at 18:20
  • @Tobias Oh gosh. *That* is huge. … I just checked and this project too has a few thousand files. A lot of those are build artifacts; narrowing the scope of the search yields about 1300 files. Whatever it is, +100 is a lot of search results to come through. :) – Ashton Wiersdorf Feb 27 '20 at 18:24
  • Maybe, [elgrep](https://github.com/TobiasZawada/elgrep) can help you. You can give regexp for the directories and files you want to search. Furthermore, you have multiple search criteria for each file. You can even split each file into search records. That should allow you to narrow the hits. – Tobias Feb 27 '20 at 18:33
  • 1
    For your case I do use `rg.el` which ask about where to search and and some other options. Also use counsel and a few others tool wrappers as convenience. – Muihlinn Jun 17 '20 at 23:03
  • Note that `helm-do-ag` as mentioned in this answer seems to work: https://stackoverflow.com/questions/39982412/projectile-search-only-part-of-the-project – xji Apr 09 '23 at 15:23

1 Answers1

2

You can also try C-u M-x project-find-regexp.

It's a part of the project package, built-in in the latest versions of Emacs but also distributed through GNU ELPA.

Be warned though: this calling convention doesn't honor the .gitignore entries (only ignores standard "junk" files and utility directories). So if you have a lot of files in the subdirectory as well, it could take a while.

Dmitry
  • 3,508
  • 15
  • 20