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: Wed, 02 Aug 2017 23:09:57 -0400 Message-ID: <87wp6l73ei.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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1501729756 774 195.159.176.226 (3 Aug 2017 03:09:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 3 Aug 2017 03:09:16 +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 Thu Aug 03 05:09:08 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 1dd6VX-0008Ay-VY for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Aug 2017 05:09:08 +0200 Original-Received: from localhost ([::1]:56911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dd6Vc-00013x-6T for geb-bug-gnu-emacs@m.gmane.org; Wed, 02 Aug 2017 23:09:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dd6VV-00012T-DV for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2017 23:09:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dd6VS-0007DX-4h for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2017 23:09:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dd6VR-0007DR-Ve for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2017 23:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dd6VR-0006ew-J7 for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2017 23:09: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: Thu, 03 Aug 2017 03:09: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.150172970525555 (code B ref 27840); Thu, 03 Aug 2017 03:09:01 +0000 Original-Received: (at 27840) by debbugs.gnu.org; 3 Aug 2017 03:08:25 +0000 Original-Received: from localhost ([127.0.0.1]:39180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dd6Ur-0006e7-6D for submit@debbugs.gnu.org; Wed, 02 Aug 2017 23:08:25 -0400 Original-Received: from mail-io0-f171.google.com ([209.85.223.171]:38540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dd6Up-0006dv-TZ for 27840@debbugs.gnu.org; Wed, 02 Aug 2017 23:08:24 -0400 Original-Received: by mail-io0-f171.google.com with SMTP id g71so2029524ioe.5 for <27840@debbugs.gnu.org>; Wed, 02 Aug 2017 20:08:23 -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=6K2hHmEc8Wh6Gob96SpiDyHkdvWtS1sgf2YNEkGnek0=; b=W6slUOQKsh7/4/0a8MilXUMApnDjQylOkTaiNZBU/prpC12xdN+BUB0CaTnKpo2dKH l+DR18tCaSDf9eKLaFJw57YM44c3c+DBkk0Z1MGqLj3Iu3pM5nKqvynkQ/OvxduWXgrr 9WYUPXA1pQEn12qL5jD2EhOIwTXqC+PGBsH6ExOHsURwqMDTYbnPpCbYHMfwva15l74t mBWeDh73EgZzJQvaF4M3iGPr2ljZfSy8D6kp+X4n6PTqlbSdZc/23Z4Cgdclgi0X/9AQ tJR5LK6W3fKG6kZ0qIpZozNXKb5B7Jv0+XKdanBVUh/VnXPmzQ1xEdz+htTaZRC2HMU7 bIAA== 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=6K2hHmEc8Wh6Gob96SpiDyHkdvWtS1sgf2YNEkGnek0=; b=OrQFRmJ7+qgj/M77DQIQKu41/B2lUUNygyrQ43M2YAKcxQHh6hhsrs9BnVg94Pm2Ci iK27tnFiVcsRHgx4AeVoce3l95wTMeyj00G/kohIFuJ/0WrAj8Elb8wEl/xg64dL912o YfsjYkDyYU7NYCtKO90zgI5HwNxYW+VOWfgsVw/9kDOYsUu/qzRG2YzUAc6hBgEE1OZA rrpA7HF8JWxs7DVt95cnKQBXhsrNkkeSwxqQTvOf3Nk67DHPA5XjjC9+LNyUG8pVmYaR fMZSoNCqMdWjNbhGGYt0S7bHq5z5i4sxHaGxMw/82pgptJluurn977+dnIbYTdlmTHcA rcJA== X-Gm-Message-State: AHYfb5iGGBAQrW+OSc1zEoRMPhfllBiQfSY4Jml3Nb8clac77jgzkgZq LTKLxCe1H2fP1A== X-Received: by 10.107.147.66 with SMTP id v63mr222632iod.126.1501729698443; Wed, 02 Aug 2017 20:08:18 -0700 (PDT) Original-Received: from zony ([45.2.119.48]) by smtp.googlemail.com with ESMTPSA id c2sm2758565itd.43.2017.08.02.20.08.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Aug 2017 20:08:17 -0700 (PDT) In-Reply-To: <17696669-9155-d7d2-ffe3-97bb62ceb733@yandex.ru> (Dmitry Gutov's message of "Tue, 1 Aug 2017 16:36:17 +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:135263 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov writes: > Alternatively, one regexp would have to handle both versions, with and > without null (merging grep-with-null-regexp-alist and > grep-fallback-regexp-alist together, if it's at all possible). It is possible, the regexp gets a bit more complicated and the without-null case can now become confused by files containing NUL bytes, but that's probably fairly rare and things do get simpler again for callers. Seems like the best solution overall. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v2-0001-Merge-null-and-without-null-regexp-alists-Bug-278.patch Content-Description: patch >From a556574087226edd1f2aa9f3834a5dfb7968080c Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 30 Jul 2017 11:07:01 -0400 Subject: [PATCH v2] Merge null and without-null regexp alists (Bug#27840, Bug#27873) * lisp/progmodes/grep.el (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/progmodes/xref.el (xref-collect-matches): Use the variable `grep-regexp-alist' rather than the function. --- lisp/progmodes/grep.el | 86 ++++++++++++++++++++++---------------------------- lisp/progmodes/xref.el | 2 +- 2 files changed, 39 insertions(+), 49 deletions(-) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 61b82df46a..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.") @@ -783,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 --=-=-=--