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.

3 Answers 3

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.

2
  • 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, 2021 at 2:46
  • You’re right; I totally missed that.
    – db48x
    Jun 22, 2021 at 7: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>’.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.