nebucatnetzer,
@nebucatnetzer@emacs.ch avatar

Does someone know how to solve this?
I would like to git grep only in the current extension with .

https://github.com/minad/consult/discussions/1016

holgerschurig,

@nebucatnetzer The first part of your answer is to use consult-ripgrep with an argument. For me, it is bound to M-s r (search with ripgrep). And so I would type C-u M-s r.

Then consult-ripgrep asks for a start directory OR the files. This is from consult-grep help text, which is implemented in the same fashion as consule-ripgrep:

If consult-grep is called interactively with a prefix argument, the user can specify the directories or files to search in.

So the real solution would be:

a) determine the extension of the current buffer name
b) (call-interactively (consult-ripgrep (file-expand-wildcards "*.el"))) ;; of course with the extension you detected, not with this constant!

That is, unfortunately consult-ripgrep doesn't by itself process the "*.el" wildcard. This is btw how ripgrep itself seems to work. If you do on the command line this:

rg foo *.el

then it's the shell that expands "*.el". See yourself with

echo *.el

Ripgrep doesn't do this, e.g. run it like this:

ripgrep foo "*.el"

and it will complain that it didn't find a file named "*.el".

So it's not too weird that the wildcard expansion is ought to be done in Emacs.

nebucatnetzer,
@nebucatnetzer@emacs.ch avatar

@holgerschurig Thank you very much for your reply, I think you misread my post however.
I‘m trying to use consult-git-grep not ripgrep.

holgerschurig,

@nebucatnetzer

Well, but the same applies to ALL of these functions. Use C-h f on consult-grep, consult-ripgrep and consult-git-grep. And you either see the C-u thing or two texts saying

See consult-grep for details.

And this text exists even for consult-git-grep.

And I'm fully aware that this is not the full solution, this is why I wrote "this is part of the answer".

nebucatnetzer,
@nebucatnetzer@emacs.ch avatar

@holgerschurig This approach only seems to be working for a few files. When I expand all my *.el files it complains about too many files.

Looks like the approach used with counsel is the correct one for consult as well.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • emacs
  • DreamBathrooms
  • ngwrru68w68
  • InstantRegret
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • tacticalgear
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • ethstaker
  • JUstTest
  • GTA5RPClips
  • modclub
  • tester
  • Leos
  • osvaldo12
  • cisconetworking
  • everett
  • cubers
  • normalnudes
  • anitta
  • megavids
  • provamag3
  • lostlight
  • All magazines