[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27873: 26.0.50; M-x grep broken
bug#27873: 26.0.50; M-x grep broken
Sun, 30 Jul 2017 11:32:31 -0400
Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)
tags 27873 + patch
Eric Hanchrow <address@hidden> writes:
> This displayed a *grep* buffer that looked something like I expected,
> * instead of there being exactly one line with some underlining
> (indicating a "hit"), there were a bunch: the one I expected, as well
> as a few before it like this:
> grep: git-repositories: Is a directory
> grep: guix: Is a directory
> grep: homedir: Is a directory
> grep: homework: Is a directory
> grep: iTunesDSM: Is a directory
> grep: jessie64: Is a directory
> grep: local: Is a directory
> grep: log: Is a directory
> grep: mygo: Is a directory
> grep: node_modules: Is a directory
> grep: perl5: Is a directory
> phonetic-alphabet.txt1:Stolen from
> grep: pprof: Is a directory
> You can't tell from what I've pasted above, but the 9 "Is a directory"
> lines before the actual hit were red and underlined, just like the
> match was.
> * Hitting C-x `, instead of visiting the file with the hit, put a
> nine-line-high prompt in the minibuffer, as if it was asking me which
> directory to find the file in a directory with a really weird name.
> (You can see some evedince of this in the "Recent messages" stuff below).
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27840 is a similar report from
> a few days ago.
It's not a duplicate though, this bug is because I thought using --null
would make it possible to get filenames containing newlines
unambiguously, but I was wrong. Here's a patch, also covers a couple of
minor issues that came up later in Bug#6843.
>From a6fae71f7f1ea5774a85f4b4238c9d7e4ed4e132 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
Date: Sun, 30 Jul 2017 11:07:01 -0400
Subject: [PATCH v1] Don't take multiples lines of grep output as a single
* lisp/progmodes/grep.el (grep-with-null-regexp-alist): Exclude
newlines from the filename part of the regexp. We must assume
filenames don't have newlines to avoid ambiguity with "foo is a
directory" messages. Use 'face nil' instead of 'face unspecified',
the latter causes errors (albeit demoted to messsages). Also renumber
FILE and LINE regexp groups to match the without-null regexp.
(grep-without-null-regexp-alist): Rename from
lisp/progmodes/grep.el | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 4723290fbe..483a1c49ff 100644
@@ -384,16 +384,22 @@ (defconst grep--regexp-alist-column
(mend (and mbeg (next-single-property-change mbeg
'font-lock-face nil end))))
(- mend beg)))))))
'("^Binary file \\(.+\\) matches$" 1 nil nil 0 1))
- `(("^\\([^\0]+\\)\\(\0\\)\\([0-9]+\\)\\([\0:]\\)" 1 3
,grep--regexp-alist-column nil nil
- (2 '(face unspecified display ":"))
- (4 '(face unspecified display ":")))
+ `(;; Use explicit numbering to keep FILE and LINE groups the same
+ ;; for both regexp alists.
+ 1 2 ,grep--regexp-alist-column nil nil
+ (3 '(face nil display ":"))
+ (4 '(face nil display ":")))
"Regexp used to match grep hits.
`(;; Use a tight regexp to handle weird file names (with colons
;; in them) as well as possible. E.g., use [1-9][0-9]* rather
;; than [0-9]+ so as to accept ":034:" in file names.
@@ -401,7 +407,8 @@ (defconst grep-fallback-regexp-alist
1 2 ,grep--regexp-alist-column)
"Regexp used to match grep hits when `--null' is not supported.
+See `compilation-error-regexp-alist' and
(defvaralias 'grep-regex-alist 'grep-with-null-regexp-alist)