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#27840: 26.0.50; vc-git-grep stopped working on git master Date: Fri, 04 Aug 2017 18:31:45 -0400 Message-ID: <87tw1n6k32.fsf@users.sourceforge.net> References: <87shhj3wtc.fsf@pokyo> <87inie93lp.fsf@users.sourceforge.net> <07272ad0-8cd0-f75e-1cf7-8f66e1d77466@yandex.ru> <8760e994rv.fsf@users.sourceforge.net> <17696669-9155-d7d2-ffe3-97bb62ceb733@yandex.ru> <87wp6l73ei.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1501885886 12287 195.159.176.226 (4 Aug 2017 22:31:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 4 Aug 2017 22:31:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 27840@debbugs.gnu.org, Tom Tromey To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 05 00:31:20 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 1ddl7n-0002mE-EN for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Aug 2017 00:31:19 +0200 Original-Received: from localhost ([::1]:54577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddl7t-00011l-Cb for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Aug 2017 18:31:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddl7b-000114-M3 for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2017 18:31:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddl7W-00073v-KR for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2017 18:31:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39427) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddl7W-00073a-F7 for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2017 18:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ddl7V-0006Wg-Ue for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2017 18:31:01 -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: Fri, 04 Aug 2017 22:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27840 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27840-submit@debbugs.gnu.org id=B27840.150188581425030 (code B ref 27840); Fri, 04 Aug 2017 22:31:01 +0000 Original-Received: (at 27840) by debbugs.gnu.org; 4 Aug 2017 22:30:14 +0000 Original-Received: from localhost ([127.0.0.1]:42104 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddl6j-0006Ve-F8 for submit@debbugs.gnu.org; Fri, 04 Aug 2017 18:30:13 -0400 Original-Received: from mail-io0-f196.google.com ([209.85.223.196]:34228) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddl6h-0006VR-VH for 27840@debbugs.gnu.org; Fri, 04 Aug 2017 18:30:12 -0400 Original-Received: by mail-io0-f196.google.com with SMTP id m88so1927408iod.1 for <27840@debbugs.gnu.org>; Fri, 04 Aug 2017 15:30:11 -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=aPtTIRU2HyZboaMcFlBcrAlVGic87H+iA5G/zsZjXp8=; b=meAuC0mVKw4LrynMFqn356MFki1fa+/GfDHxWEw59FGgzvX72yZb3lOg/PuGXAoMgu TEYQS5s8KWu5qlTGHRPgn3R41TmHv4RRSaylHs+0uIUwT/dg2Kmi2/jDXgwd0fjAcGoL e7+bfTB2WnSbhhCn0Vp6DKn+ZQJev7Da7qf8Ujx1Si20tGMVf/+ZUoVbIEBM+TcUaKM5 22tD8VIu2+Tv+fr2cQpqm9fLZPESjZa1yCTXxN31gjjRX55k0oo3/LVRRXJCEX8+3ycE TF+mSLcsAXHMJK2tT7bFBL+eQ+mS1R+8I3HqPDkUydUeazllJ6VAhqhT1hp9vOdbBj8Q SM1Q== 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=aPtTIRU2HyZboaMcFlBcrAlVGic87H+iA5G/zsZjXp8=; b=DCRpvm4yuB9RmqH6K+KEStz9xoxm4Ori5MwWkCftcenHby1OzFfEU+/pBl0xS/JP/y OqXgq/dzZQVkzwyinA8af54LqR1dMbmA5juIpNEiyFI2P3Kufm9GgS56j0koT9Atbho/ 3XQj8A8ZFxj75TkzPEcYX0SUGboGymjyRzSiLIizBvMfCXSXqu9XPUwa9UsYZwI1PZ71 ZrKyR0BafCQLnJDwxVAYGPWAJKJ1TloGV+Wwz9Xw2huGEnoUf2fDaMgC3hDoxYbMc5nn 6ET0kSy66iVjoz1Hp7/akjqR9QlwGVs8eorw/JmGxjCOD6f5WujAKB2NktHQowCiQ3hG ytVQ== X-Gm-Message-State: AIVw110zSO73uPqriTxU4IaRr8GpaA+K5xP5ZIC5QmhUZj8ABIy3u+o3 g/t6zkcoYzA0fA== X-Received: by 10.107.157.144 with SMTP id g138mr4452557ioe.200.1501885806264; Fri, 04 Aug 2017 15:30:06 -0700 (PDT) Original-Received: from zony ([45.2.119.48]) by smtp.googlemail.com with ESMTPSA id e12sm1211379itd.37.2017.08.04.15.30.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Aug 2017 15:30:04 -0700 (PDT) In-Reply-To: (Dmitry Gutov's message of "Fri, 4 Aug 2017 03:59:31 +0300") 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:135363 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov writes: > Also semantic/symref/grep.el. I fixed it before in a separate patch, > but let's keep this update all together. Oops! Thanks for reminding me. I also noticed that I had missed handling 'grep --null --after/before-context=N ...' output correctly. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v3-0001-Merge-null-and-without-null-regexp-alists-Bug-278.patch Content-Description: patch >From a13241d8c0c126c7690166b51cb507ea11f746d6 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 30 Jul 2017 14:47:05 -0400 Subject: [PATCH v3] Merge null and without-null regexp alists (Bug#27840, Bug#27873) * lisp/progmodes/grep.el (grep-mode-font-lock-keywords): Allow for NUL characters following filename in grep context lines. (grep--regexp-alist-column, grep--regexp-alist-bin-matcher) (grep-with-null-regexp-alist, grep-fallback-regexp-alist): Remove. (grep-regexp-alist): Recombine their contents here. (grep-mode): * lisp/cedet/semantic/symref/grep.el (semantic-symref-parse-tool-output-one-line): * lisp/progmodes/xref.el (xref-collect-matches): Use the variable `grep-regexp-alist' rather than the function. --- lisp/cedet/semantic/symref/grep.el | 2 +- lisp/progmodes/grep.el | 90 +++++++++++++++++--------------------- lisp/progmodes/xref.el | 2 +- 3 files changed, 43 insertions(+), 51 deletions(-) diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index df71508da7..f7c72bfb0b 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -193,7 +193,7 @@ (cl-defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref- "Parse one line of grep output, and return it as a match list. Moves cursor to end of the match." (pcase-let - ((`(,grep-re ,file-group ,line-group . ,_) (car (grep-regexp-alist)))) + ((`(,grep-re ,file-group ,line-group . ,_) (car grep-regexp-alist))) (cond ((eq (oref tool :resulttype) 'file) ;; Search for files (when (re-search-forward "^\\([^\n]+\\)$" nil t) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 2ddaf884bc..466b524c79 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -31,7 +31,6 @@ (require 'compile) - (defgroup grep nil "Run `grep' and display the results." :group 'tools @@ -366,53 +365,44 @@ (defvar grep-last-buffer nil Notice that using \\[next-error] or \\[compile-goto-error] modifies `compilation-last-buffer' rather than `grep-last-buffer'.") -(defconst grep--regexp-alist-column - ;; Calculate column positions (col . end-col) of first grep match on a line - (cons - (lambda () - (when grep-highlight-matches - (let* ((beg (match-end 0)) - (end (save-excursion (goto-char beg) (line-end-position))) - (mbeg (text-property-any beg end 'font-lock-face 'grep-match-face))) - (when mbeg - (- mbeg beg))))) - (lambda () - (when grep-highlight-matches - (let* ((beg (match-end 0)) - (end (save-excursion (goto-char beg) (line-end-position))) - (mbeg (text-property-any beg end 'font-lock-face 'grep-match-face)) - (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]+\\):" 1 3 ,grep--regexp-alist-column nil nil - (2 '(face unspecified display ":"))) - ,grep--regexp-alist-bin-matcher) - "Regexp used to match grep hits. -See `compilation-error-regexp-alist'.") -(defconst grep-fallback-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. - ("^\\(.*?[^/\n]\\):[ \t]*\\([1-9][0-9]*\\)[ \t]*:" - 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'.") - -(defvaralias 'grep-regex-alist 'grep-with-null-regexp-alist) -(make-obsolete-variable - 'grep-regex-alist "Call `grep-regexp-alist' instead." "26.1") - ;;;###autoload -(defun grep-regexp-alist () - "Return a regexp alist to match grep hits. -The regexp used depends on `grep-use-null-filename-separator'. -See `compilation-error-regexp-alist' for format details." - (if grep-use-null-filename-separator - grep-with-null-regexp-alist grep-fallback-regexp-alist)) +(defconst grep-regexp-alist + `((,(concat "^\\(?:" + ;; Parse using NUL characters when `--null' is used. + ;; Note that we must still assume no newlines in + ;; filenames due to "foo: Is a directory." type + ;; messages. + "\\(?1:[^\0\n]+\\)\\(?3:\0\\)\\(?2:[0-9]+\\):" + "\\|" + ;; Fallback if `--null' is not used, 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. + "\\(?1:[^\n:]+?[^\n/:]\\):[\t ]*\\(?2:[1-9][0-9]*\\)[\t ]*:" + "\\)") + 1 2 + ;; Calculate column positions (col . end-col) of first grep match on a line + (,(lambda () + (when grep-highlight-matches + (let* ((beg (match-end 0)) + (end (save-excursion (goto-char beg) (line-end-position))) + (mbeg (text-property-any beg end 'font-lock-face 'grep-match-face))) + (when mbeg + (- mbeg beg))))) + . + ,(lambda () + (when grep-highlight-matches + (let* ((beg (match-end 0)) + (end (save-excursion (goto-char beg) (line-end-position))) + (mbeg (text-property-any beg end 'font-lock-face 'grep-match-face)) + (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end)))) + (when mend + (- mend beg)))))) + nil nil + (3 '(face nil display ":"))) + ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) + "Regexp used to match grep hits. +See `compilation-error-regexp-alist' for format details.") (defvar grep-first-column 0 ; bug#10594 "Value to use for `compilation-first-column' in grep buffers.") @@ -451,7 +441,9 @@ (defvar grep-mode-font-lock-keywords (2 grep-error-face nil t)) ;; "filename-linenumber-" format is used for context lines in GNU grep, ;; "filename=linenumber=" for lines with function names in "git grep -p". - ("^.+?[-=][0-9]+[-=].*\n" (0 grep-context-face))) + ("^.+?\\([-=\0]\\)[0-9]+\\([-=]\\).*\n" (0 grep-context-face) + (1 (if (eq (char-after (match-beginning 1)) ?\0) + `(face nil display ,(match-string 2)))))) "Additional things to highlight in grep output. This gets tacked on the end of the generated expressions.") @@ -781,7 +773,7 @@ (define-compilation-mode grep-mode "Grep" (set (make-local-variable 'compilation-error-face) grep-hit-face) (set (make-local-variable 'compilation-error-regexp-alist) - (grep-regexp-alist)) + grep-regexp-alist) ;; compilation-directory-matcher can't be nil, so we set it to a regexp that ;; can never match. (set (make-local-variable 'compilation-directory-matcher) '("\\`a\\`")) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index cc9b794c5a..35a5c8862f 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -929,7 +929,7 @@ (defun xref-collect-matches (regexp files dir ignores) (expand-file-name dir) ignores)) (buf (get-buffer-create " *xref-grep*")) - (`(,grep-re ,file-group ,line-group . ,_) (car (grep-regexp-alist))) + (`(,grep-re ,file-group ,line-group . ,_) (car grep-regexp-alist)) (status nil) (hits nil)) (with-current-buffer buf -- 2.11.1 --=-=-=--