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

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

bug#41766: Make it possible to change regexp to identify and highlight g


From: Dmitry Gutov
Subject: bug#41766: Make it possible to change regexp to identify and highlight grep matches via customization
Date: Tue, 9 Jun 2020 03:44:47 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

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?





reply via email to

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