1

I have projects where *.nim files are the source files and *.js files are the "compiled" files.

When I issue projectile-grep (or project-find-regexp) in these projects I get both source and compiled JavaScript files returned, but of course I do not want the JavaScript files.

How can I tell project(ile) on a project-base only to return the source files (here *.nim and *.nims)?


PS: I know I can give projectile-grep a glob with a prefix argument, but this is cumbersome to do for every search in this type of project.

Drew
  • 75,699
  • 9
  • 109
  • 225
halloleo
  • 1,215
  • 9
  • 23

3 Answers3

1

The help for projectile-grep mentions the setting projectile-grep-default-files. I believe that you could use directory–local variables to set this to the correct value on a per–project basis, but I’ve not tried it myself.

Personally I use Ripgrep instead of grep. Ripgrep honors the .gitignore files that my projects all have, so it already ignores compiled files and concentrates on the correct source files.

db48x
  • 15,741
  • 1
  • 19
  • 23
  • Thanks for chiming in, but `projectile-grep-default-files` is a function. Changing this would be quite fiddling and for sure only the very last resort... – halloleo Jun 22 '21 at 02:46
  • You’re right; I totally missed that. – db48x Jun 22 '21 at 07:35
1

C-u M-x project-find-regexp.

See its documentation,

project-find-regexp is an interactive Lisp closure in ‘project.el.gz’.

(project-find-regexp REGEXP)

  Probably introduced at or before Emacs version 25.1.

Find all matches for REGEXP in the current project’s roots.
With C-u prefix, you can specify the directory
to search in, and the file name pattern to search for.  The
pattern may use abbreviations defined in ‘grep-files-aliases’,
e.g. entering ‘ch’ is equivalent to ‘*.[ch]’.  As whitespace
triggers completion when entering a pattern, including it
requires quoting, e.g. ‘M-x quoted-insert<space>’.
chen bin
  • 4,781
  • 18
  • 36
0

On a per-project-base you can use the .projectile file to exclude JavaScript files. Create a .projectile file at the root of your project with a line like

-*.js

In Nim projects in particular you probably want to add all nimcache folders as well with

-nimcache

Please note: You need to switch to hybrid or native indexing in projectile. If you want to do this globally, just add for example

(setq projectile-indexing-method 'hybrid)

to your .emacs file or in your projectile use-package expression.

halloleo
  • 1,215
  • 9
  • 23