From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#27873: 26.0.50; M-x grep broken Date: Sun, 30 Jul 2017 11:32:31 -0400 Message-ID: <87a83m7xf4.fsf@users.sourceforge.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1501428675 3033 195.159.176.226 (30 Jul 2017 15:31:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 30 Jul 2017 15:31:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 27873@debbugs.gnu.org, Dmitry Gutov To: Eric Hanchrow Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 30 17:31:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbqBP-0000QG-FY for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Jul 2017 17:31:07 +0200 Original-Received: from localhost ([::1]:55641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbqBV-0004QQ-Hg for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Jul 2017 11:31:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbqBN-0004Mo-K1 for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 11:31:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbqBK-0003Tu-Dy for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 11:31:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59985) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dbqBK-0003TY-8f for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 11:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dbqBK-0005uR-3h for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2017 11:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jul 2017 15:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27873 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27873-submit@debbugs.gnu.org id=B27873.150142866022707 (code B ref 27873); Sun, 30 Jul 2017 15:31:02 +0000 Original-Received: (at 27873) by debbugs.gnu.org; 30 Jul 2017 15:31:00 +0000 Original-Received: from localhost ([127.0.0.1]:34429 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbqBI-0005u7-4a for submit@debbugs.gnu.org; Sun, 30 Jul 2017 11:31:00 -0400 Original-Received: from mail-it0-f67.google.com ([209.85.214.67]:34330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbqBF-0005tl-KZ; Sun, 30 Jul 2017 11:30:58 -0400 Original-Received: by mail-it0-f67.google.com with SMTP id t78so16252895ita.1; Sun, 30 Jul 2017 08:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=we0EA8P32m6voQZf7Zqbow7fOnNRQo25l5Ub4gnRVV0=; b=cgiIHJX10jcd7INSZSxLuelO2BfAllSMuY3tFbxeb4B9L39lLf4DhnfCbTsFZA0O4N pJ5JF9a5Krwn1UcVD8sImYujojK+gmker2Gtfm0IUYEZXoEqNVfNH3yngxn4hn7dDtip 0vE1pPZ60rRaJpkMohJB7cJRj0qNdQ4DSHi66EWrY1iJxaa53mX5kVUuLWxiAQs9EGUH 63tu/L9FuwJ5SZR4KuDNWBl/tHzEgxAKglUq8CypaPgEct2/71OBxDUMWzOeMN7USagt puilfLFLs8ziR+6UbOYftdxb1UrnrFIgIx9Rt29GUKJC3Gx26K/2m6SvLmEGAVtyhJ1I vc5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=we0EA8P32m6voQZf7Zqbow7fOnNRQo25l5Ub4gnRVV0=; b=XElhfJd236FSZ2B9m97vuiK7AM5NvR68PwT1az4guozX6vGGty30x3GilxSyblcQqC DDi88uO9uHs1W4q6Xq9TtMsCpP/oWw8Mhx31OnsKIEgaoz+SOZxSKjGs4OnjkV18dhTI 5QtzGuH8mpYdzjueAaqmwmEV1UXaLf45z4DfjSp31COLBrVeb0QgWqPGSnRrJSZxGDut 9g7WtAUKNhMT41MwJPXAmDSxIGa5uwHI0qbTd6Wku4Eg8cmV2rGTCaCiVHPOfaOGt0YA UioGzRzGPVf4Ewz6asw8WBg1cl+PJFa5fJ/nmVJ7Qm3woYMJX9t0rIt9rsmPrnPvMDao S5Og== X-Gm-Message-State: AIVw111rLk4NcrBSWIs4kgK9aZkOIqnNpHV68VVYNKkPoGG3bo7r/Ka0 lKvwEREqHQkODUuT X-Received: by 10.36.28.82 with SMTP id c79mr16051137itc.173.1501428651828; Sun, 30 Jul 2017 08:30:51 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id w6sm4488481itb.2.2017.07.30.08.30.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jul 2017 08:30:51 -0700 (PDT) In-Reply-To: (Eric Hanchrow's message of "Sun, 30 Jul 2017 00:02:14 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:135155 Archived-At: --=-=-= Content-Type: text/plain tags 27873 + patch quit Eric Hanchrow 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Don-t-take-multiples-lines-of-grep-output-as-a-si.patch Content-Description: patch >From a6fae71f7f1ea5774a85f4b4238c9d7e4ed4e132 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-=--