From: npostavs@users.sourceforge.net
To: Eric Hanchrow <eric.hanchrow@gmail.com>
Cc: 27873@debbugs.gnu.org, Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#27873: 26.0.50; M-x grep broken
Date: Sun, 30 Jul 2017 11:32:31 -0400 [thread overview]
Message-ID: <87a83m7xf4.fsf@users.sourceforge.net> (raw)
In-Reply-To: <CAHZoxq8iXw8ONfF1Ke5-W7FYkZFKt1=VxwWV_81Kd0wAM8_jeQ@mail.gmail.com> (Eric Hanchrow's message of "Sun, 30 Jul 2017 00:02:14 +0000")
[-- Attachment #1: Type: text/plain, Size: 1595 bytes --]
tags 27873 + patch
quit
Eric Hanchrow <eric.hanchrow@gmail.com> writes:
> This displayed a *grep* buffer that looked something like I expected,
> but:
>
> * 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 http://www.fourmilab.ch/documents/phoneticalphabet/
> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2588 bytes --]
From a6fae71f7f1ea5774a85f4b4238c9d7e4ed4e132 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 30 Jul 2017 11:07:01 -0400
Subject: [PATCH v1] Don't take multiples lines of grep output as a single
filename (Bug#27873)
* 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
`grep-fallback-regexp-alist'.
---
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
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -384,16 +384,22 @@ (defconst grep--regexp-alist-column
(mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end))))
(when mend
(- mend beg)))))))
+
(defconst grep--regexp-alist-bin-matcher
'("^Binary file \\(.+\\) matches$" 1 nil nil 0 1))
+
(defconst grep-with-null-regexp-alist
- `(("^\\([^\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:[^\0\n]+\\)\\(?3:\0\\)\\(?2:[0-9]+\\)\\(?4:[\0:]\\)"
+ 1 2 ,grep--regexp-alist-column nil nil
+ (3 '(face nil display ":"))
+ (4 '(face nil display ":")))
,grep--regexp-alist-bin-matcher)
"Regexp used to match grep hits.
See `compilation-error-regexp-alist'.")
-(defconst grep-fallback-regexp-alist
+
+(defconst grep-without-null-regexp-alist
`(;; 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)
,grep--regexp-alist-bin-matcher)
"Regexp used to match grep hits when `--null' is not supported.
-See `compilation-error-regexp-alist'.")
+See `compilation-error-regexp-alist' and
+`grep-use-null-filename-separator'.")
(defvaralias 'grep-regex-alist 'grep-with-null-regexp-alist)
(make-obsolete-variable
--
2.11.1
next prev parent reply other threads:[~2017-07-30 15:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-30 0:02 bug#27873: 26.0.50; M-x grep broken Eric Hanchrow
2017-07-30 0:08 ` bug#27873: Probably a dupe of #27840 Eric Hanchrow
2017-07-30 15:32 ` npostavs [this message]
2017-07-30 18:48 ` bug#27873: 26.0.50; M-x grep broken Eric Hanchrow
2017-07-30 20:08 ` npostavs
[not found] ` <CAHZoxq9XD5YNSz4FDX_wtWwXzpe2+zftGCk0NzXm24WBbSGGJQ@mail.gmail.com>
2017-07-30 20:34 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a83m7xf4.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=27873@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--cc=eric.hanchrow@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.