GNU bug report logs - #48302
[PATCH] Abbreviate `find' properties in M-x rgrep on MS Windows

Previous Next

Package: emacs;

Reported by: Jim Porter <jporterbugs <at> gmail.com>

Date: Sat, 8 May 2021 22:18:01 UTC

Severity: normal

Tags: patch

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48302 in the body.
You can then email your comments to 48302 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48302; Package emacs. (Sat, 08 May 2021 22:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jim Porter <jporterbugs <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 08 May 2021 22:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Abbreviate `find' properties in M-x rgrep on MS Windows
Date: Sat, 8 May 2021 15:17:14 -0700
[Message part 1 (text/plain, inline)]
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 ----------
[0001-Abbreviate-rgrep-command-when-using-MS-Windows-style.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48302; Package emacs. (Sun, 09 May 2021 06:54:02 GMT) Full text and rfc822 format available.

Message #8 received at 48302 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: 48302 <at> debbugs.gnu.org
Subject: Re: bug#48302: [PATCH] Abbreviate `find' properties in M-x rgrep on MS
 Windows
Date: Sun, 09 May 2021 09:53:32 +0300
> From: Jim Porter <jporterbugs <at> gmail.com>
> Date: Sat, 8 May 2021 15:17:14 -0700
> 
> 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.

Thanks, but could you also add a test for this issue to the test
suite?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48302; Package emacs. (Sun, 09 May 2021 20:09:03 GMT) Full text and rfc822 format available.

Message #11 received at 48302 <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 48302 <at> debbugs.gnu.org
Subject: Re: bug#48302: [PATCH] Abbreviate `find' properties in M-x rgrep on
 MS Windows
Date: Sun, 9 May 2021 13:07:42 -0700
[Message part 1 (text/plain, inline)]
On Sat, May 8, 2021 at 11:53 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> Thanks, but could you also add a test for this issue to the test
> suite?

I see some grep-related tests in
`test/lisp/progmodes/compile-tests.el', but those only cover
`grep-regexp-alist', not `grep-mode-font-lock-keywords'. Testing
grep.el's font-lock didn't seem like it would belong in
`compile-tests.el', so I've added `test/lisp/progmodes/grep-tests.el'
and included a (very) simple test for find-abbreviation. It uses the
shell-quoting semantics of whatever the current system is; it would be
nice to test all shell-quoting styles in one test run, but I wasn't
sure how to do that. Still, if automated tests are run on multiple
platforms, this should (hopefully) catch any bugs.

My Elisp skills are fairly basic, so I may have made some mistakes
here. Just let me know what (if anything) needs improved for the
tests.
[0001-Abbreviate-rgrep-command-when-using-MS-Windows-style.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48302; Package emacs. (Mon, 10 May 2021 07:43:02 GMT) Full text and rfc822 format available.

Message #14 received at 48302 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 48302 <at> debbugs.gnu.org
Subject: Re: bug#48302: [PATCH] Abbreviate `find' properties in M-x rgrep on
 MS Windows
Date: Mon, 10 May 2021 09:42:46 +0200
Jim Porter <jporterbugs <at> gmail.com> writes:

Hi Jim,

> It uses the shell-quoting semantics of whatever the current system is;
> it would be nice to test all shell-quoting styles in one test run, but
> I wasn't sure how to do that.

You could force this by let-binding system-type, like

--8<---------------cut here---------------start------------->8---
(let ((system-type 'gnu/linux))
  (rgrep-default-command "search" "*" nil)
  ...)

(let ((system-type 'darwin))
  (rgrep-default-command "search" "*" nil)
  ...)
--8<---------------cut here---------------end--------------->8---

In the windows-nt case, the function w32-shell-dos-semantics is called,
which does not exist on other systems. So you must mock it up to return
either t or nil:

--8<---------------cut here---------------start------------->8---
(let ((system-type 'windows-nt))
  (cl-letf (((symbol-function #'w32-shell-dos-semantics) #'always))
    (rgrep-default-command "search" "*" nil)
    ...))

(let ((system-type 'windows-nt))
  (cl-letf (((symbol-function #'w32-shell-dos-semantics) #'ignore))
    (rgrep-default-command "search" "*" nil)
    ...))
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48302; Package emacs. (Tue, 11 May 2021 04:37:01 GMT) Full text and rfc822 format available.

Message #17 received at 48302 <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 48302 <at> debbugs.gnu.org
Subject: [PATCH v2] Re: bug#48302: [PATCH] Abbreviate `find' properties in M-x
 rgrep on MS Windows
Date: Mon, 10 May 2021 21:36:25 -0700
[Message part 1 (text/plain, inline)]
On Mon, May 10, 2021 at 12:42 AM Michael Albinus <michael.albinus <at> gmx.de> wrote:
> > It uses the shell-quoting semantics of whatever the current system is;
> > it would be nice to test all shell-quoting styles in one test run, but
> > I wasn't sure how to do that.
>
> You could force this by let-binding system-type, like [snip]

Thanks for the pointers. Attached is an updated patch that tests the 4
cases you described.
[0001-Abbreviate-rgrep-command-when-using-MS-Windows-style.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48302; Package emacs. (Tue, 11 May 2021 07:12:01 GMT) Full text and rfc822 format available.

Message #20 received at 48302 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 48302 <at> debbugs.gnu.org
Subject: Re: [PATCH v2] Re: bug#48302: [PATCH] Abbreviate `find' properties
 in M-x rgrep on MS Windows
Date: Tue, 11 May 2021 09:11:01 +0200
Jim Porter <jporterbugs <at> gmail.com> writes:

Hi Jim,

> Thanks for the pointers. Attached is an updated patch that tests the 4
> cases you described.

Thanks. LGTM. Just one nit:

> +    (should (equal (grep-tests--get-rgrep-abbreviation) nil))))

This is (should-not (grep-tests--get-rgrep-abbreviation))

Eli, do you have further comments? Otherwise, I would commit it in Jim's
name.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48302; Package emacs. (Tue, 11 May 2021 12:23:01 GMT) Full text and rfc822 format available.

Message #23 received at 48302 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: jporterbugs <at> gmail.com, 48302 <at> debbugs.gnu.org
Subject: Re: [PATCH v2] Re: bug#48302: [PATCH] Abbreviate `find' properties
 in M-x rgrep on MS Windows
Date: Tue, 11 May 2021 15:22:48 +0300
> From: Michael Albinus <michael.albinus <at> gmx.de>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  48302 <at> debbugs.gnu.org
> Date: Tue, 11 May 2021 09:11:01 +0200
> 
> Eli, do you have further comments? Otherwise, I would commit it in Jim's
> name.

No further comments, but please be sure to mention the bug number in
the commit log message.

Thanks.




Reply sent to Michael Albinus <michael.albinus <at> gmx.de>:
You have taken responsibility. (Wed, 12 May 2021 08:50:02 GMT) Full text and rfc822 format available.

Notification sent to Jim Porter <jporterbugs <at> gmail.com>:
bug acknowledged by developer. (Wed, 12 May 2021 08:50:02 GMT) Full text and rfc822 format available.

Message #28 received at 48302-done <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: jporterbugs <at> gmail.com, 48302-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2] Re: bug#48302: [PATCH] Abbreviate `find' properties
 in M-x rgrep on MS Windows
Date: Wed, 12 May 2021 10:48:51 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Eli, do you have further comments? Otherwise, I would commit it in Jim's
>> name.
>
> No further comments, but please be sure to mention the bug number in
> the commit log message.

Done, closing the bug.

> Thanks.

Best regards, Michael.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 Jun 2021 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 321 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.