help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to set grep-find-template and grep-template to use ripgrep?


From: Mekeor Melire
Subject: How to set grep-find-template and grep-template to use ripgrep?
Date: Thu, 23 Nov 2023 13:55:15 +0000

Hello :)

How to set grep-find-template and grep-template variables to use ripgrep? I found some resources and suggestions on the web but I decided to ask here once more since readers of this mailing-list might have better configurations than what I came up with:

   (require 'grep)

(setopt grep-find-template "rg --color=auto --null --line-number --with-filename --no-heading --regexp <R> <D>") (setopt grep-template "rg --line-number --with-filename --no-heading --regexp <R> -- <F>") (setopt grep-use-null-device nil) ;; since ripgrep supports and is configured to use --with-filename

For this configuration, I merged suggestions from these two web resources:

   https://stackoverflow.com/a/45533878
   
https://github.com/seagle0128/.emacs.d/blob/03bc707f46ad54eaabad2e5a95de3137caf428c5/lisp/init-prog.el#L96

It's a pity that my value for grep-find-template only uses <R> and <D>, and does not use 
the following fields. If I understand correctly, with this configuration, I can't limit the matched 
files with a glob pattern (<F>). It doesn't seem to be trivial to use <F> with ripgrep 
because it's made specifically for GNU find.

   <X> - find options to restrict or expand the directory list
   <F> - find options to limit the files matched

Similarly, my value for grep-template does not use the following field, thus I seem to be missing out a feature:

   <C> - place to put the options like -i and --color.
   <X> - file names and wildcards to exclude.

That's why I wonder if someone already has a nice configuration for these 
variables, and possibly further configuration enabling more features here. Or 
should I rather simply expect that not all features will work with ripgrep, and 
should prefer tools like consult-ripgrep in place of the built-in lgrep and 
rgrep commands?

Thank you all and have a nice day!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]