Hi, I changed grep-regexp-match to grep-match-regexp. Pls note that ripgrep knows about ignore files etc. hence the more fair comparison would probably be git grep (e.g. vc-git-grep). But ripgrep is still considerably faster and does not only work for git repositories. Thanks! ________________________________________ From: DG on behalf of Dmitry Gutov Sent: 09 June 2020 01:44 To: Simon Lang; 41766@debbugs.gnu.org Subject: Re: bug#41766: Make it possible to change regexp to identify and highlight grep matches via customization On 08.06.2020 23:25, Simon Lang wrote: > For example: > > change grep command to > > "rg -n -H -S --no-heading --color always -e" I wonder if we can use a similar customization more generally. For instance, in my testing Grep searches the full Emacs checkout in ~230ms, whereas RipGrep does that in ~40ms. The difference is perceptible. The obvious idea is to use grep-template, but we're passing -s and -E to it. rg would interpret these options differently. Here's a perftest patch if someone was personally curious about the difference: diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 5b5fb4bc47..2c6ed4da7d 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1262,7 +1262,7 @@ xref-matches-in-files (dir (file-name-directory (car files))) (remote-id (file-remote-p dir)) ;; 'git ls-files' can output broken symlinks. - (command (format "xargs -0 grep %s -snHE -e %s" + (command (format "xargs -0 rg %s -nH -e %s" (if (and case-fold-search (isearch-no-upper-case-p regexp t)) "-i" @@ -1275,6 +1275,7 @@ xref-matches-in-files #'tramp-file-local-name #'file-local-name) files))) + (setq tt (time-to-seconds)) (with-current-buffer output (erase-buffer) (with-temp-buffer @@ -1289,6 +1290,7 @@ xref-matches-in-files shell-command-switch command))) (goto-char (point-min)) + (message "%s" (- (time-to-seconds) tt)) (when (and (/= (point-min) (point-max)) (not (looking-at grep-re)) ;; TODO: Show these matches as well somehow?