GNU bug report logs -
#23590
25.0.94; Errors in default lgrep command
Previous Next
Reported by: Alex <agrambot <at> gmail.com>
Date: Sat, 21 May 2016 00:12:01 UTC
Severity: normal
Tags: fixed, patch
Found in version 25.0.94
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
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 23590 in the body.
You can then email your comments to 23590 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 21 May 2016 00:12:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alex <agrambot <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 21 May 2016 00:12:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
The default lgrep command (`all' for the FILES argument) gives
off unexpected errors.
* When there are no hidden (dot) files in the given directory, then I
get the following error:
zsh:1: no matches found: *.
Grep exited abnormally with code 1 at ...
By default lgrep uses my default shell (zsh). Should this be the case?
Setting `shell-file-name' to "bash" fixes this error, but it still
produces the next error.
* When there are directories in the given directory (this includes . and
..) then lgrep produces an error for each directory. For example:
grep: .: Is a directory
grep: ..: Is a directory
grep: .emacs.d: Is a directory
Grep exited abnormally with code 2 at ...
In GNU Emacs 25.0.94.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.18.9)
of 2016-05-17 built on lylat
Windowing system distributor 'Fedora Project', version 11.0.11803000
Configured using:
'configure --with-gif=no'
Configured features:
XPM JPEG TIFF PNG SOUND DBUS GSETTINGS NOTIFY FREETYPE XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11
Important settings:
value of $LC_CTYPE: en_CA.utf8
value of $LANG: en_CA.utf8
value of $XMODIFIERS: @im=none
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode easymenu
cl-loaddefs pcase cl-lib mail-prsvr mail-utils thingatpt grep compile
comint ansi-color ring time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 95915 8690)
(symbols 48 20220 0)
(miscs 40 50 221)
(strings 32 16338 4494)
(string-bytes 1 485576)
(vectors 16 12554)
(vector-slots 8 436687 5729)
(floats 8 172 70)
(intervals 56 346 19)
(buffers 976 12)
(heap 1024 43598 1075))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 02:17:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Alex <agrambot <at> gmail.com> wrote:
> The default lgrep command (`all' for the FILES argument) gives
> off unexpected errors.
>
> * When there are no hidden (dot) files in the given directory, then I
> get the following error:
>
> zsh:1: no matches found: *.
> Grep exited abnormally with code 1 at ...
>
> By default lgrep uses my default shell (zsh). Should this be the case?
> Setting `shell-file-name' to "bash" fixes this error, but it still
> produces the next error.
Thanks for reporting this. I've seen it too.
The problem seems to be caused by a difference in how zsh handles globs
that don't match anything, compared to bash. I'm not sure what the right
way would be to accommodate it in Emacs. Hopefully someone will be along
shortly with ideas for that. However, there are a couple things you can
do to work around it in the meantime.
First, you could change the command used by `lgrep' to enable zsh's
NULL_GLOB option, of which the zsh documentation[1] says: "If a pattern
for filename generation has no matches, delete the pattern from the
argument list instead of reporting an error". To do that, you could use
something like:
(with-eval-after-load 'grep
(grep-apply-setting
'grep-template
"setopt null_glob; grep <X> <C> -n -e <R> <F>"))
Second, you could use advice on `lgrep' so that it invokes grep via bash
rather than zsh. That would look like:
(defun grep-use-bash (original &rest args)
(let ((shell-file-name (executable-find "bash")))
(apply original args)))
(with-eval-after-load 'grep
(advice-add 'lgrep :around #'grep-use-bash))
I tested both options only briefly; apologies if I missed any issues.
> * When there are directories in the given directory (this includes . and
> ..) then lgrep produces an error for each directory. For example:
>
>
> grep: .: Is a directory
> grep: ..: Is a directory
> grep: .emacs.d: Is a directory
>
> Grep exited abnormally with code 2 at ...
GNU Grep has an option (-d ACTION or --directories=ACTION) that can be
used to skip over directories (with "skip" as the ACTION), but it's not
in POSIX so I doubt we can use it in Emacs. If you know it will be
available on your system(s), you could add it to your `grep-template'
using the same technique as above.
[1] http://www.cs.elte.hu/zsh-manual/zsh_16.html
John
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 07:46:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 23590 <at> debbugs.gnu.org (full text, mbox):
> From: John Mastro <john.b.mastro <at> gmail.com>
> Date: Fri, 22 Jul 2016 19:16:27 -0700
> Cc: Alex <agrambot <at> gmail.com>
>
> Alex <agrambot <at> gmail.com> wrote:
> > The default lgrep command (`all' for the FILES argument) gives
> > off unexpected errors.
> >
> > * When there are no hidden (dot) files in the given directory, then I
> > get the following error:
> >
> > zsh:1: no matches found: *.
> > Grep exited abnormally with code 1 at ...
> >
> > By default lgrep uses my default shell (zsh). Should this be the case?
> > Setting `shell-file-name' to "bash" fixes this error, but it still
> > produces the next error.
>
> Thanks for reporting this. I've seen it too.
>
> The problem seems to be caused by a difference in how zsh handles globs
> that don't match anything, compared to bash. I'm not sure what the right
> way would be to accommodate it in Emacs. Hopefully someone will be along
> shortly with ideas for that.
Shell commands that Emacs emits support /bin/sh and compatible
shells. Zsh's default treatment of unmatched wildcards isn't.
I don't know how it happened that lgrep invokes zsh on OP's system,
but if that is due to user customizations, they should be corrected.
If that is Emacs's fault (i.e. Emacs invokes zsh without any
customizations), it should be fixed.
> > * When there are directories in the given directory (this includes . and
> > ..) then lgrep produces an error for each directory. For example:
> >
> >
> > grep: .: Is a directory
> > grep: ..: Is a directory
> > grep: .emacs.d: Is a directory
> >
> > Grep exited abnormally with code 2 at ...
>
> GNU Grep has an option (-d ACTION or --directories=ACTION) that can be
> used to skip over directories (with "skip" as the ACTION), but it's not
> in POSIX so I doubt we can use it in Emacs. If you know it will be
> available on your system(s), you could add it to your `grep-template'
> using the same technique as above.
Yes, but I don't understand why the OP says these are errors. They
aren't; they are just informative messages from Grep.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 16:58:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> wrote:
> Shell commands that Emacs emits support /bin/sh and compatible
> shells. Zsh's default treatment of unmatched wildcards isn't.
>
> I don't know how it happened that lgrep invokes zsh on OP's system,
> but if that is due to user customizations, they should be corrected.
> If that is Emacs's fault (i.e. Emacs invokes zsh without any
> customizations), it should be fixed.
Emacs invokes whichever shell is the value of the user's SHELL
environment variable.
My reading of the code is that this is the result of a call chain from
`lgrep', to `compilation-start', to `start-file-process-shell-command',
to `start-file-process'. The only way `shell-file-name' is disregarded
in favor of /bin/sh is if `default-directory' is remote:
(defun start-file-process-shell-command (name buffer &rest args)
(start-file-process
...
(if (file-remote-p default-directory) "/bin/sh" shell-file-name)
...))
And shell-file-name is initialized to the value of SHELL in
init_callproc():
char *sh;
...
sh = getenv ("SHELL");
Vshell_file_name = build_string (sh ? sh : "/bin/sh");
So the user may not have intended to customize Emacs per se, but setting
SHELL does so indirectly.
This is my first time looking at most of this code but, if the intent is
for `lgrep' to always use /bin/sh, the least ugly way I see of doing
that is to let-bind `shell-file-name' in `lgrep'.
Obviously it would remain the case that Emacs uses shell-file-name for
other commands, but since AFAIK that hasn't been a problem more
generally a minimal change may be best.
> Yes, but I don't understand why the OP says these are errors. They
> aren't; they are just informative messages from Grep.
I'm guessing this was just a misunderstanding about how `lgrep' works.
If the reporter thought of it as "call grep on all files", and didn't
think of directories as files, then it might be surprising at first to
see those messages.
John
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 17:12:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 23590 <at> debbugs.gnu.org (full text, mbox):
John Mastro <john.b.mastro <at> gmail.com> writes:
> (with-eval-after-load 'grep
> (grep-apply-setting
> 'grep-template
> "setopt null_glob; grep <X> <C> -n -e <R> <F>"))
> GNU Grep has an option (-d ACTION or --directories=ACTION) that can be
> used to skip over directories (with "skip" as the ACTION), but it's not
> in POSIX so I doubt we can use it in Emacs. If you know it will be
> available on your system(s), you could add it to your `grep-template'
> using the same technique as above.
Thanks, these workarounds work exactly as you said. It does seem that
outside of setting null_glob somewhere, there isn't a way to get zsh to
behave correctly.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 17:16:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 23590 <at> debbugs.gnu.org (full text, mbox):
> From: John Mastro <john.b.mastro <at> gmail.com>
> Date: Sat, 23 Jul 2016 09:57:02 -0700
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Alex <agrambot <at> gmail.com>
>
> Eli Zaretskii <eliz <at> gnu.org> wrote:
> > Shell commands that Emacs emits support /bin/sh and compatible
> > shells. Zsh's default treatment of unmatched wildcards isn't.
> >
> > I don't know how it happened that lgrep invokes zsh on OP's system,
> > but if that is due to user customizations, they should be corrected.
> > If that is Emacs's fault (i.e. Emacs invokes zsh without any
> > customizations), it should be fixed.
>
> Emacs invokes whichever shell is the value of the user's SHELL
> environment variable.
Then maybe we should change that.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 17:24:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> wrote:
>> Emacs invokes whichever shell is the value of the user's SHELL
>> environment variable.
>
> Then maybe we should change that.
Do you mean for `lgrep' specifically or at a lower level? To be honest,
I don't have a good enough feel for the implications to have a strong
opinion.
This is admittedly an anecdote but, having used zsh as my SHELL (and
`shell-file-name') for several years, this scenario with `lgrep' and the
"all" alias is the only time I've run into a problem.
John
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 17:29:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> Shell commands that Emacs emits support /bin/sh and compatible
> shells. Zsh's default treatment of unmatched wildcards isn't.
>
> I don't know how it happened that lgrep invokes zsh on OP's system,
> but if that is due to user customizations, they should be corrected.
> If that is Emacs's fault (i.e. Emacs invokes zsh without any
> customizations), it should be fixed.
shell-file-name is set to zsh (as it's my default user shell) in emacs
-Q as well. This can be useful for commands like ansi-term. If an Emacs
program expects full sh compatibility, then perhaps there could be an
extra variable they can check before falling back to shell-file-name?
>> GNU Grep has an option (-d ACTION or --directories=ACTION) that can be
>> used to skip over directories (with "skip" as the ACTION), but it's not
>> in POSIX so I doubt we can use it in Emacs. If you know it will be
>> available on your system(s), you could add it to your `grep-template'
>> using the same technique as above.
>
> Yes, but I don't understand why the OP says these are errors. They
> aren't; they are just informative messages from Grep.
When I use lgrep I already know that I'm not going to be searching
directories. I find such messages to be useless clutter.
Additionally, while zsh doesn't error on this part (with the workarounds
that John provided), bash does appear to error because it is including
directories:
Grep exited abnormally with code 2 at ...
PS:
I noticed that between 25.0.94 and 25.0.95 the default command changes
slightly. It now includes a wildcard ..?* that bash doesn't seem to like
if there are no matching files:
grep: ..?*: No such file or directory
Grep exited abnormally with code 2 at ...
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 17:59:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 23590 <at> debbugs.gnu.org (full text, mbox):
> From: John Mastro <john.b.mastro <at> gmail.com>
> Date: Sat, 23 Jul 2016 10:23:20 -0700
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Alex <agrambot <at> gmail.com>
>
> Eli Zaretskii <eliz <at> gnu.org> wrote:
> >> Emacs invokes whichever shell is the value of the user's SHELL
> >> environment variable.
> >
> > Then maybe we should change that.
>
> Do you mean for `lgrep' specifically or at a lower level?
No, I mean in general.
> This is admittedly an anecdote but, having used zsh as my SHELL (and
> `shell-file-name') for several years, this scenario with `lgrep' and the
> "all" alias is the only time I've run into a problem.
Why would you want to use zsh in commands issued by lgrep?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 18:01:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 23590 <at> debbugs.gnu.org (full text, mbox):
> From: Alex <agrambot <at> gmail.com>
> Cc: John Mastro <john.b.mastro <at> gmail.com>, 23590 <at> debbugs.gnu.org
> Date: Sat, 23 Jul 2016 11:28:21 -0600
>
> > Yes, but I don't understand why the OP says these are errors. They
> > aren't; they are just informative messages from Grep.
>
> When I use lgrep I already know that I'm not going to be searching
> directories. I find such messages to be useless clutter.
They cannot be avoided portably. Sorry.
> Additionally, while zsh doesn't error on this part (with the workarounds
> that John provided), bash does appear to error because it is including
> directories:
>
> Grep exited abnormally with code 2 at ...
Because of this:
> grep: ..?*: No such file or directory
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 18:19:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 23590 <at> debbugs.gnu.org (full text, mbox):
> Date: Sat, 23 Jul 2016 21:00:37 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: john.b.mastro <at> gmail.com, 23590 <at> debbugs.gnu.org
>
> > Grep exited abnormally with code 2 at ...
>
> Because of this:
>
> > grep: ..?*: No such file or directory
Actually, I see that "Is a directory" also caused exit code of 2. So
I guess patches are welcome to add --directory=skip to the Grep
command when a preliminary test reveals that Grep supports it.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 19:54:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii wrote:
> Why would you want to use zsh in commands issued by lgrep?
Not in the "commands issued by lgrep", but in the glob pattern passed to lgrep.
One wants to use the same shell as one is used to using interactively,
so that one can use that shell's glob patterns, if it has specific ones,
as zsh does. (I'm not a zsh user.)
I don't think forcing it to use bash is the right solution.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Sat, 23 Jul 2016 22:14:01 GMT)
Full text and
rfc822 format available.
Message #41 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Date: Sat, 23 Jul 2016 21:00:37 +0300
>> From: Eli Zaretskii <eliz <at> gnu.org>
>> Cc: john.b.mastro <at> gmail.com, 23590 <at> debbugs.gnu.org
>>
>> > Grep exited abnormally with code 2 at ...
>>
>> Because of this:
>>
>> > grep: ..?*: No such file or directory
>
> Actually, I see that "Is a directory" also caused exit code of 2. So
> I guess patches are welcome to add --directory=skip to the Grep
> command when a preliminary test reveals that Grep supports it.
Is the following patch acceptable?
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index f04a722..c696f75 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -573,10 +573,14 @@ This function is called from `compilation-filter-hook'."
grep-template grep-find-template)
(let ((grep-options
(concat (if grep-use-null-device "-n" "-nH")
- (if (grep-probe grep-program
- `(nil nil nil "-e" "foo" ,null-device)
- nil 1)
- " -e"))))
+ (when (grep-probe grep-program
+ `(nil nil nil "--directories=skip" "foo" ,null-device)
+ nil 1)
+ " --directories=skip")
+ (when (grep-probe grep-program
+ `(nil nil nil "-e" "foo" ,null-device)
+ nil 1)
+ " -e"))))
(unless grep-command
(setq grep-command
(format "%s %s %s " grep-program
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Fri, 04 Sep 2020 14:11:01 GMT)
Full text and
rfc822 format available.
Message #44 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Alex <agrambot <at> gmail.com> writes:
>> Actually, I see that "Is a directory" also caused exit code of 2. So
>> I guess patches are welcome to add --directory=skip to the Grep
>> command when a preliminary test reveals that Grep supports it.
>
> Is the following patch acceptable?
There was discussion here before the patch was posted, but then no
follow-up. I've respun the patch for Emacs 28 -- does anybody have any
comments?
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index c71a90344f..17f0422ac7 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -696,10 +696,15 @@ grep-compute-defaults
(let ((grep-options
(concat (if grep-use-null-device "-n" "-nH")
(if grep-use-null-filename-separator " --null")
- (if (grep-probe grep-program
- `(nil nil nil "-e" "foo" ,null-device)
- nil 1)
- " -e"))))
+ (when (grep-probe grep-program
+ `(nil nil nil "--directories=skip" "foo"
+ ,null-device)
+ nil 1)
+ " --directories=skip")
+ (when (grep-probe grep-program
+ `(nil nil nil "-e" "foo" ,null-device)
+ nil 1)
+ " -e"))))
(unless grep-command
(setq grep-command
(format "%s %s %s " grep-program
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) patch.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Fri, 04 Sep 2020 14:11:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Wed, 07 Oct 2020 03:43:01 GMT)
Full text and
rfc822 format available.
Message #49 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> There was discussion here before the patch was posted, but then no
> follow-up. I've respun the patch for Emacs 28 -- does anybody have any
> comments?
There were no comments in a month, and the patch makes sense to me, so
I've applied it to Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) fixed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Wed, 07 Oct 2020 03:43:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 28.1, send any further explanations to
23590 <at> debbugs.gnu.org and Alex <agrambot <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Wed, 07 Oct 2020 03:43:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Wed, 07 Oct 2020 08:18:02 GMT)
Full text and
rfc822 format available.
Message #56 received at 23590 <at> debbugs.gnu.org (full text, mbox):
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: john.b.mastro <at> gmail.com, Eli Zaretskii <eliz <at> gnu.org>,
> 23590 <at> debbugs.gnu.org
> Date: Wed, 07 Oct 2020 05:41:56 +0200
>
> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
> > There was discussion here before the patch was posted, but then no
> > follow-up. I've respun the patch for Emacs 28 -- does anybody have any
> > comments?
>
> There were no comments in a month, and the patch makes sense to me, so
> I've applied it to Emacs 28.
I'm sorry to not have chimed earlier, but I think this change goes too
far. Now the default "M-x grep" command includes --directories=skip
if the user's Grep program supports that. This is not a good idea for
the general-purpose Grep commands. For example, if the user adds to
the default command "-R foo" somewhere before the --directories=skip
part, the command will say "no matches", which would be a surprise at
best, and at worst could mislead the user.
The original bug report was about "M-x lgrep". Can we make this
change affect only that command?
In any case, this is a user-visible change, so it should be called out
in NEWS.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Fri, 09 Oct 2020 04:16:01 GMT)
Full text and
rfc822 format available.
Message #59 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> The original bug report was about "M-x lgrep". Can we make this
> change affect only that command?
>
> In any case, this is a user-visible change, so it should be called out
> in NEWS.
Yup, and yup.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Tue, 13 Oct 2020 20:20:02 GMT)
Full text and
rfc822 format available.
Message #62 received at 23590 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> The original bug report was about "M-x lgrep". Can we make this
>> change affect only that command?
>>
>> In any case, this is a user-visible change, so it should be called out
>> in NEWS.
>
> Yup, and yup.
The latest fix has two problems:
1. it runs grep-probe every time lgrep is used;
2. it adds --directories=skip to the end of the command after regexp and file names
This patch improves both:
[grep-use-directories-skip.patch (text/x-diff, inline)]
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index f028a4279d..9b1dc337e8 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -959,10 +959,10 @@ grep-expand-keywords
these include `opts', `dir', `files', `null-device', `excl' and
`regexp'.")
-(defun grep-expand-template (template &optional regexp files dir excl)
+(defun grep-expand-template (template &optional regexp files dir excl more-opts)
"Expand grep COMMAND string replacing <C>, <D>, <F>, <R>, and <X>."
(let* ((command template)
- (env `((opts . ,(let (opts)
+ (env `((opts . ,(let ((opts more-opts))
(when (and case-fold-search
(isearch-no-upper-case-p regexp t))
(push "-i" opts))
@@ -1058,6 +1058,8 @@ grep-read-files
(or (cdr (assoc files grep-files-aliases))
files))))
+(defvar grep-use-directories-skip 'auto-detect)
+
;;;###autoload
(defun lgrep (regexp &optional files dir confirm)
"Run grep, searching for REGEXP in FILES in directory DIR.
@@ -1103,6 +1105,12 @@ lgrep
(if (string= command grep-command)
(setq command nil))
(setq dir (file-name-as-directory (expand-file-name dir)))
+ (unless (or (not grep-use-directories-skip) (eq grep-use-directories-skip t))
+ (setq grep-use-directories-skip
+ (grep-probe grep-program
+ `(nil nil nil "--directories=skip" "foo"
+ ,null-device)
+ nil 1)))
(setq command (grep-expand-template
grep-template
regexp
@@ -1119,13 +1127,10 @@ lgrep
(shell-quote-argument
(cdr ignore))))))
grep-find-ignored-files
- " --exclude=")))))
+ " --exclude=")))
+ (and grep-use-directories-skip
+ '("--directories=skip"))))
(when command
- (when (grep-probe grep-program
- `(nil nil nil "--directories=skip" "foo"
- ,null-device)
- nil 1)
- (setq command (concat command " --directories=skip")))
(if confirm
(setq command
(read-from-minibuffer "Confirm: "
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23590
; Package
emacs
.
(Wed, 14 Oct 2020 04:11:01 GMT)
Full text and
rfc822 format available.
Message #65 received at 23590 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
> 1. it runs grep-probe every time lgrep is used;
> 2. it adds --directories=skip to the end of the command after regexp
> and file names
>
> This patch improves both:
Looks good; go ahead and push.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 11 Nov 2020 12:24:10 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 299 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.