GNU bug report logs - #78269
diff-outline-regexp

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Juri Linkov <juri@HIDDEN>; Done: Juri Linkov <juri@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
bug marked as fixed in version 31.0.50, send any further explanations to 78269 <at> debbugs.gnu.org and Juri Linkov <juri@HIDDEN> Request was from Juri Linkov <juri@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 78269 <at> debbugs.gnu.org:


Received: (at 78269) by debbugs.gnu.org; 7 May 2025 06:34:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 07 02:34:49 2025
Received: from localhost ([127.0.0.1]:39169 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uCYMj-00072U-5T
	for submit <at> debbugs.gnu.org; Wed, 07 May 2025 02:34:49 -0400
Received: from relay1-d.mail.gandi.net ([217.70.183.193]:41791)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>)
 id 1uCYMf-00071p-GY; Wed, 07 May 2025 02:34:46 -0400
Received: by mail.gandi.net (Postfix) with ESMTPSA id 08D3043A4E;
 Wed,  7 May 2025 06:34:35 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#78269: diff-outline-regexp
In-Reply-To: <jwvfrhisn08.fsf-monnier+emacs@HIDDEN>
Organization: LINKOV.NET
References: <87y0vazxem.fsf@HIDDEN>
 <jwvfrhisn08.fsf-monnier+emacs@HIDDEN>
Date: Wed, 07 May 2025 09:31:20 +0300
Message-ID: <87ldr99blv.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-State: clean
X-GND-Score: -100
X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvkeeiudehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopegtohhnthhrohhlseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepjeekvdeileesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehmohhnnhhivghrsehirhhordhumhhonhhtrhgvrghlrdgtrg
X-GND-Sasl: juri@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 78269
Cc: 78269 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

close 78269 31.0.50
thanks

>> -    (setq diff-outline-regexp
>> +    (setq-local diff-outline-regexp
>
> LGTM, thanks.
>
>> Probably no one noticed this problem because its current default value
>> is not useful to anyone:
>>
>>   (defvar diff-outline-regexp
>>     "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)")
>
> I think the idea was to recognize file header and hunk headers, in the
> case where the "diff" command itself is absent (as is the case in the
> output of the (non-recursive) `diff` command).
>
>> Maybe the default should be replaced with something like
>>
>>   (defvar diff-outline-regexp
>>     (concat "\\(^diff -.*\\|" diff-hunk-header-re "\\)"))
>
> LGTM (I'd even drop the `-` after `diff`).  AFAICT nowadays the "diff
> ..." command is absent only in cases where there's only one file in the
> diff, so matching the file header is not very useful, indeed.

So now pushed.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#78269; Package emacs. Full text available.

Message received at 78269 <at> debbugs.gnu.org:


Received: (at 78269) by debbugs.gnu.org; 5 May 2025 22:42:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 05 18:42:19 2025
Received: from localhost ([127.0.0.1]:44014 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uC4Vu-0006d3-N2
	for submit <at> debbugs.gnu.org; Mon, 05 May 2025 18:42:19 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39381)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1uC4Vs-0006ck-1I
 for 78269 <at> debbugs.gnu.org; Mon, 05 May 2025 18:42:16 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 27C5710013E;
 Mon,  5 May 2025 18:42:10 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1746484929;
 bh=4Uko6kYbwcSuF0ymXiJyWxW114qnVLnr0yiLjvutoyc=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=TFM7sC+naIomtP+yD5FfogDbY+zUeG5PJZa8eKTk13GT1gYA3a0mvNiYSiK9eDfmQ
 qEfTJ1pbsHHriWqafEm0vrJLvBfVwse2dTmSy9G+1rkdUjaRnRV9SgQa4XqqHXhTsP
 WLsEldtNuf46+qiZph+let43cR761oa8QPYp3Fz8j3E2z9P0M/eSl2tZgclOXEm62Y
 oEzp191R7HsmqWWweipWXtFf4rYv44hsNa59TQmV4eDyVox0uLLUMpc7pMN+uIyGi4
 kxhwSI1rXEHB07TjVk94tegpGxnHGQdKDba6EkvjFZ3UceQIDaSMtDWvUVxZvkPYte
 rgZ0mvKEMX7vQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 3C3AA10002E;
 Mon,  5 May 2025 18:42:09 -0400 (EDT)
Received: from alfajor (104-195-232-56.cpe.teksavvy.com [104.195.232.56])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0BABE120185;
 Mon,  5 May 2025 18:42:09 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Juri Linkov <juri@HIDDEN>
Subject: Re: bug#78269: diff-outline-regexp
In-Reply-To: <87y0vazxem.fsf@HIDDEN>
Message-ID: <jwvfrhisn08.fsf-monnier+emacs@HIDDEN>
References: <87y0vazxem.fsf@HIDDEN>
Date: Mon, 05 May 2025 18:42:07 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.218 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78269
Cc: 78269 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
> index a5f4169a7f3..76703526b63 100644
> --- a/lisp/vc/diff-mode.el
> +++ b/lisp/vc/diff-mode.el
> @@ -1719,7 +1719,7 @@ diff-setup-buffer-type
>                        'hg
>                      nil))))
>    (when (eq diff-buffer-type 'git)
> -    (setq diff-outline-regexp
> +    (setq-local diff-outline-regexp
>            (concat "\\(^diff --git.*\\|" diff-hunk-header-re "\\)")))
>    (setq-local outline-level #'diff--outline-level)
>    (setq-local outline-regexp diff-outline-regexp))

LGTM, thanks.

> Probably no one noticed this problem because its current default value
> is not useful to anyone:
>
>   (defvar diff-outline-regexp
>     "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)")

I think the idea was to recognize file header and hunk headers, in the
case where the "diff" command itself is absent (as is the case in the
output of the (non-recursive) `diff` command).

> Maybe the default should be replaced with something like
>
>   (defvar diff-outline-regexp
>     (concat "\\(^diff -.*\\|" diff-hunk-header-re "\\)"))

LGTM (I'd even drop the `-` after `diff`).  AFAICT nowadays the "diff
..." command is absent only in cases where there's only one file in the
diff, so matching the file header is not very useful, indeed.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#78269; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 5 May 2025 19:11:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 05 15:11:48 2025
Received: from localhost ([127.0.0.1]:43112 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uC1EB-0003pe-Kx
	for submit <at> debbugs.gnu.org; Mon, 05 May 2025 15:11:48 -0400
Received: from lists.gnu.org ([2001:470:142::17]:54502)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1uC1E8-0003pC-6y
 for submit <at> debbugs.gnu.org; Mon, 05 May 2025 15:11:45 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1uC1E2-0000LJ-EI
 for bug-gnu-emacs@HIDDEN; Mon, 05 May 2025 15:11:38 -0400
Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1uC1Dz-000150-Sa
 for bug-gnu-emacs@HIDDEN; Mon, 05 May 2025 15:11:38 -0400
Received: by mail.gandi.net (Postfix) with ESMTPSA id 296811FCE9
 for <bug-gnu-emacs@HIDDEN>; Mon,  5 May 2025 19:11:30 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: diff-outline-regexp
Organization: LINKOV.NET
X-Debbugs-Cc: Stefan Monnier <monnier@HIDDEN>
Date: Mon, 05 May 2025 22:10:25 +0300
Message-ID: <87y0vazxem.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-State: clean
X-GND-Score: 0
X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvkeduledtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvufhofffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeejgffgtddthfelteejkeejueegvdekgfdufffgtdehvddtkeetveehgfffjeeuteenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepuddprhgtphhtthhopegsuhhgqdhgnhhuqdgvmhgrtghssehgnhhurdhorhhg
X-GND-Sasl: juri@HIDDEN
Received-SPF: pass client-ip=2001:4b98:dc4:8::223;
 envelope-from=juri@HIDDEN; helo=relay3-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

I noticed that 'diff-setup-buffer-type' overrides the default value
of 'diff-outline-regexp'.  Here is the fix:

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index a5f4169a7f3..76703526b63 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1719,7 +1719,7 @@ diff-setup-buffer-type
                       'hg
                     nil))))
   (when (eq diff-buffer-type 'git)
-    (setq diff-outline-regexp
+    (setq-local diff-outline-regexp
           (concat "\\(^diff --git.*\\|" diff-hunk-header-re "\\)")))
   (setq-local outline-level #'diff--outline-level)
   (setq-local outline-regexp diff-outline-regexp))

Probably no one noticed this problem because its current default value
is not useful to anyone:

  (defvar diff-outline-regexp
    "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)")

Maybe the default should be replaced with something like

  (defvar diff-outline-regexp
    (concat "\\(^diff -.*\\|" diff-hunk-header-re "\\)"))

that is useful for file-based diff.  Or maybe the value for file-based diff
should be set in 'diff-no-select' like this?

diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el
index c8a1b7c0efa..62c4ba6d302 100644
--- a/lisp/vc/diff.el
+++ b/lisp/vc/diff.el
@@ -196,6 +196,9 @@ diff-no-select
 	(erase-buffer))
       (buffer-enable-undo (current-buffer))
       (diff-mode)
+      (setq-local diff-outline-regexp
+                  (concat "\\(^" diff-command ".*\\|" diff-hunk-header-re "\\)")
+                  outline-regexp diff-outline-regexp)
       (setq-local revert-buffer-function
                   (lambda (_ignore-auto _noconfirm)
                     (diff-no-select old new switches no-async (current-buffer))))

But I might be missing more use cases.




Acknowledgement sent to Juri Linkov <juri@HIDDEN>:
New bug report received and forwarded. Copy sent to monnier@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to monnier@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#78269; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 7 May 2025 06:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.