unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41766: Make it possible to change regexp to identify and highlight grep matches via customization
@ 2020-06-08 20:25 Simon Lang
  2020-06-08 23:18 ` Juri Linkov
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Simon Lang @ 2020-06-08 20:25 UTC (permalink / raw)
  To: 41766

[-- Attachment #1: Type: text/plain, Size: 496 bytes --]

When changing grep-command or grep-find-command to e.g. ripgrep matches are not highlighted in the grep buffer. This patches makes the regexp that is used to identify matches customizable and hence possible to adapt it to potential grep replacements.

For example:

change  grep command to 

"rg -n -H -S --no-heading --color always -e "

and grep-match-regexp to

"\033\\[[0-9]*m\033\\[[0-9]*1m\033\\[[0-9]*1m\\(.*?\\)\033\\[[0-9]*0m"

to get correct highlighting with ripgrep.



[-- Attachment #2: 0001-Make-regexp-used-to-highlight-grep-matches-customiza.patch --]
[-- Type: application/octet-stream, Size: 1421 bytes --]

From 0916b4efa6661cd3f6ad9889cfea83580bf17fe9 Mon Sep 17 00:00:00 2001
From: Simon Lang <simon.lang@outlook.com>
Date: Mon, 8 Jun 2020 20:47:08 +0100
Subject: [PATCH] Make regexp used to highlight grep matches customizable

* lisp/progmodes/grep.el
---
 lisp/progmodes/grep.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 7731be5965..08c8ca071b 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -100,6 +100,9 @@ To change the default value, use \\[customize] or call the function
   :set #'grep-apply-setting
   :version "22.1")
 
+(defcustom grep-regexp-match "\033\\[0?1;31m\\(.*?\\)\033\\[[0-9]*m"
+  "Regex definition to identify grep markers to highlight matches.")
+
 (defcustom grep-scroll-output nil
   "Non-nil to scroll the *grep* buffer window as output appears.
 
@@ -584,7 +587,7 @@ This function is called from `compilation-filter-hook'."
       (when (< (point) end)
         (setq end (copy-marker end))
         ;; Highlight grep matches and delete marking sequences.
-        (while (re-search-forward "\033\\[0?1;31m\\(.*?\\)\033\\[[0-9]*m" end 1)
+        (while (re-search-forward grep-regexp-match end 1)
           (replace-match (propertize (match-string 1)
                                      'face nil 'font-lock-face grep-match-face)
                          t t)
-- 
2.21.0 (Apple Git-122)


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2020-09-27 12:56 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0e6ad4aefa2743f1b0d6ba4315a9e91b@VI1PR10MB2800.EURPRD10.PROD.OUTLOOK.COM>
2020-06-14  9:12 ` bug#41766: Make it possible to change regexp to identify and highlight grep matches via customization Simon Lang
2020-06-14 23:08   ` Juri Linkov
2020-06-22 19:09     ` Simon Lang
2020-06-22 23:50       ` Juri Linkov
2020-06-08 20:25 Simon Lang
2020-06-08 23:18 ` Juri Linkov
2020-06-09  0:44 ` Dmitry Gutov
2020-06-09  7:58   ` Simon Lang
2020-06-09 11:55     ` Basil L. Contovounesios
2020-06-09 12:45       ` Simon Lang
2020-06-09 14:32         ` Basil L. Contovounesios
2020-06-09 14:43       ` Eli Zaretskii
2020-06-10 21:11         ` Simon Lang
2020-06-10 21:52           ` Juri Linkov
2020-06-10 22:14             ` Dmitry Gutov
2020-06-10 23:10               ` Juri Linkov
2020-06-10 23:24                 ` Dmitry Gutov
2020-06-13  9:51                 ` Simon Lang
2020-06-13 22:50                   ` Juri Linkov
2020-06-13  6:50           ` Eli Zaretskii
2020-06-13  9:48             ` Simon Lang
2020-09-27 12:56               ` Lars Ingebrigtsen
2020-06-09 12:15     ` Dmitry Gutov
2020-06-09 12:41       ` Simon Lang
2020-06-09 14:24 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).