unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48302: [PATCH] Abbreviate `find' properties in M-x rgrep on MS Windows
@ 2021-05-08 22:17 Jim Porter
  2021-05-09  6:53 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Jim Porter @ 2021-05-08 22:17 UTC (permalink / raw)
  To: 48302

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

MS Windows has different shell-quoting logic from POSIX shells, so the
regexp to abbreviate the `find' command's properties in rgrep fails to
match on MS Windows. The attached patch fixes this by looking for
either `\)' (POSIX) or `")"' (MS Windows) as the end of the properties
list.

Steps to reproduce:

  ;; Ensure GNU find and grep are in your path
  emacs -Q
  M-x rgrep RET foo RET RET RET
  ;; See the full, unabbreviated command instead of `find [...] -exec grep'...

To make things easier to review for people without access to MS
Windows, this is the full invocation for rgrep:

---------- Begin Block ----------

find . -type d "(" -path "*/SCCS" -o -path "*/RCS" -o -path "*/CVS" -o
-path "*/MCVS" -o -path "*/.src" -o -path "*/.svn" -o -path "*/.git"
-o -path "*/.hg" -o -path "*/.bzr" -o -path "*/_MTN" -o -path
"*/_darcs" -o -path "*/{arch}" ")" -prune -o ^"^!^" -type d "(" -name
".#*" -o -name "*.o" -o -name "*~" -o -name "*.bin" -o -name "*.bak"
-o -name "*.obj" -o -name "*.map" -o -name "*.ico" -o -name "*.pif" -o
-name "*.lnk" -o -name "*.a" -o -name "*.ln" -o -name "*.blg" -o -name
"*.bbl" -o -name "*.dll" -o -name "*.drv" -o -name "*.vxd" -o -name
"*.386" -o -name "*.elc" -o -name "*.lof" -o -name "*.glo" -o -name
"*.idx" -o -name "*.lot" -o -name "*.fmt" -o -name "*.tfm" -o -name
"*.class" -o -name "*.fas" -o -name "*.lib" -o -name "*.mem" -o -name
"*.x86f" -o -name "*.sparcf" -o -name "*.dfsl" -o -name "*.pfsl" -o
-name "*.d64fsl" -o -name "*.p64fsl" -o -name "*.lx64fsl" -o -name
"*.lx32fsl" -o -name "*.dx64fsl" -o -name "*.dx32fsl" -o -name
"*.fx64fsl" -o -name "*.fx32fsl" -o -name "*.sx64fsl" -o -name
"*.sx32fsl" -o -name "*.wx64fsl" -o -name "*.wx32fsl" -o -name
"*.fasl" -o -name "*.ufsl" -o -name "*.fsl" -o -name "*.dxl" -o -name
"*.lo" -o -name "*.la" -o -name "*.gmo" -o -name "*.mo" -o -name
"*.toc" -o -name "*.aux" -o -name "*.cp" -o -name "*.fn" -o -name
"*.ky" -o -name "*.pg" -o -name "*.tp" -o -name "*.vr" -o -name
"*.cps" -o -name "*.fns" -o -name "*.kys" -o -name "*.pgs" -o -name
"*.tps" -o -name "*.vrs" -o -name "*.pyc" -o -name "*.pyo" ")" -prune
-o  -type f "(" -iname "*" -o -iname ^".[^!.]*^" -o -iname "..?*" ")"
-exec grep --color=always -i -nH --null "foo" "{}" ";"

---------- End Block ----------

[-- Attachment #2: 0001-Abbreviate-rgrep-command-when-using-MS-Windows-style.patch --]
[-- Type: application/octet-stream, Size: 1060 bytes --]

From 6760457c78cc0bd29305f5989130012c142a108a Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 8 May 2021 14:54:20 -0700
Subject: [PATCH] Abbreviate rgrep command when using MS Windows-style
 shell-quoting

lisp/progmodes/grep.el (grep-mode-font-lock-keywords): Adapt regexp to match
MS Windows-style shell-quoting.
---
 lisp/progmodes/grep.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index e9fbcbbfcd..80c3e7840f 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -473,7 +473,7 @@ grep-mode-font-lock-keywords
       (1 (if (eq (char-after (match-beginning 1)) ?\0)
              `(face nil display ,(match-string 2)))))
      ;; Hide excessive part of rgrep command
-     ("^find \\(\\. -type d .*\\\\)\\)"
+     ("^find \\(\\. -type d .*\\(?:\\\\)\\|\")\"\\)\\)"
       (1 (if grep-find-abbreviate grep-find-abbreviate-properties
            '(face nil abbreviated-command t))))
      ;; Hide excessive part of lgrep command
-- 
2.25.1


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

end of thread, other threads:[~2021-05-12  8:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-08 22:17 bug#48302: [PATCH] Abbreviate `find' properties in M-x rgrep on MS Windows Jim Porter
2021-05-09  6:53 ` Eli Zaretskii
2021-05-09 20:07   ` Jim Porter
2021-05-10  7:42     ` Michael Albinus
2021-05-11  4:36       ` bug#48302: [PATCH v2] " Jim Porter
2021-05-11  7:11         ` Michael Albinus
2021-05-11 12:22           ` Eli Zaretskii
2021-05-12  8:48             ` Michael Albinus

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).