From unknown Fri Aug 15 02:03:37 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#20276 <20276@debbugs.gnu.org> To: bug#20276 <20276@debbugs.gnu.org> Subject: Status: 24.4; diff-mode doesn't handle unified diff file headers without tabs Reply-To: bug#20276 <20276@debbugs.gnu.org> Date: Fri, 15 Aug 2025 09:03:37 +0000 retitle 20276 24.4; diff-mode doesn't handle unified diff file headers with= out tabs reassign 20276 emacs submitter 20276 Gustav H=C3=A5llberg severity 20276 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 07 18:34:57 2015 Received: (at submit) by debbugs.gnu.org; 7 Apr 2015 22:34:57 +0000 Received: from localhost ([127.0.0.1]:48359 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfc5A-0007f4-JQ for submit@debbugs.gnu.org; Tue, 07 Apr 2015 18:34:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52752) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfc58-0007eq-2V for submit@debbugs.gnu.org; Tue, 07 Apr 2015 18:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yfc51-0002my-J8 for submit@debbugs.gnu.org; Tue, 07 Apr 2015 18:34:48 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yfc51-0002mu-Gw for submit@debbugs.gnu.org; Tue, 07 Apr 2015 18:34:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yfc50-0006Yt-Ck for bug-gnu-emacs@gnu.org; Tue, 07 Apr 2015 18:34:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yfc4z-0002mk-7E for bug-gnu-emacs@gnu.org; Tue, 07 Apr 2015 18:34:46 -0400 Received: from mail-la0-x236.google.com ([2a00:1450:4010:c03::236]:36233) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yfc4y-0002mg-UT for bug-gnu-emacs@gnu.org; Tue, 07 Apr 2015 18:34:45 -0400 Received: by lagv1 with SMTP id v1so53158868lag.3 for ; Tue, 07 Apr 2015 15:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=LDapcvO2H8uuRYYWmoERAI9/BWXnzFMcn/zZCKF/EBM=; b=cNKqxNWQ3/eZlN4DPj0v9Aga0R5oeztD9708EG9IjDSUkQOjvEr9/yXUgVdDT322Zn r2x6TGPsR7qarT83OHC6yUtyb7yN/QqxZxq4mS2Q75GgoMdyhm4AXTgBM+sM9J1b5Fp5 2076HLVZZbWG9hVWBBzCK6K91umRi7zj7IhQuOxRFeGlHVk84hydB/oCQrqg4yAMLwaD Yt05tBAByI7Xk9ZZ+DdVObrAW5uQsdR7v05fOm5x0x58rbfcqwuzOYHEht5lDo/K3emV Fvs9sKJDDBfQ5M6F1lsRFziyUrKJ+cDt92oKDrCz/1xqs4XxcjZDSLR+l3dtkwOTSHs5 Cv9w== X-Received: by 10.152.87.162 with SMTP id az2mr20832280lab.58.1428446083962; Tue, 07 Apr 2015 15:34:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.24.167 with HTTP; Tue, 7 Apr 2015 15:34:23 -0700 (PDT) From: =?UTF-8?Q?Gustav_H=C3=A5llberg?= Date: Wed, 8 Apr 2015 00:34:23 +0200 Message-ID: Subject: 24.4; diff-mode doesn't handle unified diff file headers without tabs To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary=001a11c33f286a5f5e05132a05bc X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --001a11c33f286a5f5e05132a05bc Content-Type: text/plain; charset=UTF-8 In diff-mode, "o" doesn't recognize unified diff file headers if they do not contain tabs. Some diff programs will not emit tab + timestamp (as GNU diff does), but just the file name. Example working file header (where ".txt" is followed by tabs): --- a.txt 2015-04-08 00:09:46.000000000 +0200 +++ b.txt 2015-04-08 00:09:51.000000000 +0200 Example failing file header: --- a.txt +++ b.txt The fallback is for "o" to open the file on the leading "diff" line which may or may not be present. This used to work in Emacs 24.3.1 but does not as of the patch mentioned here: http://stackoverflow.com/questions/14720205/how-do-i-use-emacs-diff-with-spaces My proposal is to fix this in (diff-hunk-file-names) by removing the requirement for the trailing tab on the leading diff file header and replace it with a no-newline check (sorry for not providing proper patch): - (if (looking-at "[-*][-*][-*] \\([^\t]+\\)\t.*\n[-+][-+][-+] \\([^\t]+\\)") + (if (looking-at "[-*][-*][-*] \\([^\t\n]+\\).*\n[-+][-+][-+] \\([^\t\n]+\\)") The return values should probably use (match-string-no-properties) rather than (match-string) as well. Thanks, Gustav --001a11c33f286a5f5e05132a05bc Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
In diff-mode, "o" doesn't recognize uni= fied diff file headers if they do
not contain tabs. Some diff pro= grams will not emit tab + timestamp (as
GNU diff does), but just = the file name.

Example working file header (where = ".txt" is followed by tabs):

--- a.txt 2015-04-08 00:09:46.000000= 000 +0200
+++ b.txt 2015-04-08 00:09:51.000000000 +0200

Example f= ailing file header:

--- a.txt
+++ b.txt<= /div>

The fallback is for "o" to open the file= on the leading "diff" line
which may or may not be pre= sent.

This used to work in Emacs 24.3.1 but does n= ot as of the patch mentioned
here:

My proposal is to fix this in (diff-hunk-fil= e-names) by removing the
requirement for the trailing tab on the = leading diff file header and
replace it with a no-newline check (= sorry for not providing proper
patch):

-= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (looking-at "[-*][-*][-*] \\([^= \t]+\\)\t.*\n[-+][-+][-+] \\([^\t]+\\)")
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(if (looking-at "[-*][-*][-*] \\([^\t\n]+\\).*\n[-+][= -+][-+] \\([^\t\n]+\\)")

The return values sh= ould probably use (match-string-no-properties)
rather than (match= -string) as well.

Thanks,
=C2=A0Gustav

--001a11c33f286a5f5e05132a05bc-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 08 16:50:38 2015 Received: (at 20276) by debbugs.gnu.org; 8 Apr 2015 20:50:38 +0000 Received: from localhost ([127.0.0.1]:49565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfwvm-0004LH-2D for submit@debbugs.gnu.org; Wed, 08 Apr 2015 16:50:38 -0400 Received: from mercure.iro.umontreal.ca ([132.204.24.67]:33158) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfwvi-0004L8-VA for 20276@debbugs.gnu.org; Wed, 08 Apr 2015 16:50:35 -0400 Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 88D169C128; Wed, 8 Apr 2015 16:50:34 -0400 (EDT) Received: from lechon.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 8FE531E5B8C; Wed, 8 Apr 2015 16:50:06 -0400 (EDT) Received: by lechon.iro.umontreal.ca (Postfix, from userid 20848) id 73644B4122; Wed, 8 Apr 2015 16:50:06 -0400 (EDT) From: Stefan Monnier To: Gustav =?windows-1252?Q?H=E5llberg?= Subject: Re: bug#20276: 24.4; diff-mode doesn't handle unified diff file headers without tabs Message-ID: References: Date: Wed, 08 Apr 2015 16:50:06 -0400 In-Reply-To: ("Gustav =?windows-1252?Q?H=E5llberg=22's?= message of "Wed, 8 Apr 2015 00:34:23 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82, MC_TSTLAST 0.00) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-Spam-Status: No X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 20276 Cc: 20276@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) > Some diff programs will not emit tab + timestamp (as GNU diff does), > but just the file name. Which diff programs do that? > - (if (looking-at "[-*][-*][-*] \\([^\t]+\\)\t.*\n[-+][-+][-+] > \\([^\t]+\\)") > + (if (looking-at "[-*][-*][-*] \\([^\t\n]+\\).*\n[-+][-+][-+] > \\([^\t\n]+\\)") Adding \n in the char-ranges is fine (it's a good change in itself), but removing the \t increases the risk of false positives, so I'm a bit worried about that. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 08 18:39:24 2015 Received: (at 20276) by debbugs.gnu.org; 8 Apr 2015 22:39:24 +0000 Received: from localhost ([127.0.0.1]:49645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfyd2-0006u3-5j for submit@debbugs.gnu.org; Wed, 08 Apr 2015 18:39:24 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:32788) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yfycz-0006tp-Kd for 20276@debbugs.gnu.org; Wed, 08 Apr 2015 18:39:22 -0400 Received: by lbbzk7 with SMTP id zk7so78163479lbb.0 for <20276@debbugs.gnu.org>; Wed, 08 Apr 2015 15:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=AKMca7+Xk3ZWrtaarlLVCZmQZNpR4JbI2cv1MIJWqq8=; b=EV1k66/GzCc5R5iI1pLKi3RWXPhLxtXja/W102aumdRF7I1JhZJyrf6abXkZAiaH2I fb6atAu5iEkJXfVBb4jYrL6Iie/nzxHniSFHWorJxK68coDpGK/mXYGM8CQ5FvyhfFDq 5N2FxaFIwy99zc+LuQLTwKK5tyA8DAOHSZoDrnZo8BTCnw6SZKkQm34Hgg1Nouyqsb9E PLopottX88wgj0VPqjomK0k4+v8i8xqoIf8kHEM+dHbZpQR7P5mYpjiMfQOMnqAuXfuA b0OP2cZIMyArVk/5giq7U/SrG9pcuFhr29b0HGHR8BE3j12v24SlyJO4e6qYYQAEjTce +s8w== X-Received: by 10.112.235.38 with SMTP id uj6mr25814300lbc.9.1428532755721; Wed, 08 Apr 2015 15:39:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.24.167 with HTTP; Wed, 8 Apr 2015 15:38:55 -0700 (PDT) In-Reply-To: References: From: =?UTF-8?Q?Gustav_H=C3=A5llberg?= Date: Thu, 9 Apr 2015 00:38:55 +0200 Message-ID: Subject: Re: bug#20276: 24.4; diff-mode doesn't handle unified diff file headers without tabs To: Stefan Monnier Content-Type: multipart/alternative; boundary=001a11c3cf2874727105133e336d X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 20276 Cc: 20276@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a11c3cf2874727105133e336d Content-Type: text/plain; charset=UTF-8 On Wed, Apr 8, 2015 at 10:50 PM, Stefan Monnier wrote: > > Some diff programs will not emit tab + timestamp (as GNU diff does), > > but just the file name. > > Which diff programs do that? > diff -u with -L does for example: $ diff -u -Lfoo a.txt -Lbar b.txt --- foo +++ bar : git diff also does for what it's worth. > > > - (if (looking-at "[-*][-*][-*] \\([^\t]+\\)\t.*\n[-+][-+][-+] > > \\([^\t]+\\)") > > + (if (looking-at "[-*][-*][-*] \\([^\t\n]+\\).*\n[-+][-+][-+] > > \\([^\t\n]+\\)") > > Adding \n in the char-ranges is fine (it's a good change in itself), but > removing the \t increases the risk of false positives, so I'm a bit > worried about that. > True, but note that diff-font-lock-keywords is more permissive; it does not require the tab to be present. - Gustav > > > Stefan > --001a11c3cf2874727105133e336d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On W= ed, Apr 8, 2015 at 10:50 PM, Stefan Monnier <monnier@iro.umontrea= l.ca> wrote:
> Some diff programs will= not emit tab + timestamp (as GNU diff does),
> but just the file name.

Which diff programs do that?

diff -u with -L= does for example:

=C2=A0 $ diff -u -Lfoo a.txt -Lbar b.txt
=C2=A0 --- foo
=C2=A0 +++ bar
<= div>=C2=A0 =C2=A0 :

git diff also does for what it= 's worth.
=C2=A0

> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (looking-at "[-*][-*][-*]= \\([^\t]+\\)\t.*\n[-+][-+][-+]
> \\([^\t]+\\)")
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (looking-at "[-*][-*][-*]= \\([^\t\n]+\\).*\n[-+][-+][-+]
> \\([^\t\n]+\\)")

Adding \n in the char-ranges is fine (it's a good change in itself), bu= t
removing the \t increases the risk of false positives, so I'm a bit
worried about that.

True, but note that= diff-font-lock-keywords is more permissive; it does not require the tab to= be present.

- Gustav

=C2= =A0


=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan

--001a11c3cf2874727105133e336d-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 08 21:48:57 2015 Received: (at 20276-done) by debbugs.gnu.org; 9 Apr 2015 01:48:57 +0000 Received: from localhost ([127.0.0.1]:49746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yg1aT-0004KG-9m for submit@debbugs.gnu.org; Wed, 08 Apr 2015 21:48:57 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:56309) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yg1aR-0004K4-S5 for 20276-done@debbugs.gnu.org; Wed, 08 Apr 2015 21:48:56 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgUFAGvvdVRBbthL/2dsb2JhbAA3gVOhb4EIgXUBAQQBViMFCws0EhQYDSSIE6IRjA0aPQkDAQKDPgMOAQEECINUBKg7 X-IPAS-Result: AgUFAGvvdVRBbthL/2dsb2JhbAA3gVOhb4EIgXUBAQQBViMFCws0EhQYDSSIE6IRjA0aPQkDAQKDPgMOAQEECINUBKg7 X-IronPort-AV: E=Sophos;i="5.01,1,1400040000"; d="scan'208";a="115765653" Received: from 65-110-216-75.cpe.pppoe.ca (HELO pastel.home) ([65.110.216.75]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Apr 2015 21:48:51 -0400 Received: by pastel.home (Postfix, from userid 20848) id 058B620AC; Wed, 8 Apr 2015 21:48:49 -0400 (EDT) From: Stefan Monnier To: Gustav =?windows-1252?Q?H=E5llberg?= Subject: Re: bug#20276: 24.4; diff-mode doesn't handle unified diff file headers without tabs Message-ID: References: Date: Wed, 08 Apr 2015 21:48:49 -0400 In-Reply-To: ("Gustav =?windows-1252?Q?H=E5llberg=22's?= message of "Thu, 9 Apr 2015 00:38:55 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 20276-done Cc: 20276-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > git diff also does for what it's worth. Ah, indeed. This doesn't bite us too hard because git also happens to provide the "diff ..." line. > True, but note that diff-font-lock-keywords is more permissive; it does not > require the tab to be present. Of course a false positive in diff-font-lock-keywords will only look funny but won't affect actual behavior, which is why I thought it was OK to be more permissive. Anyway, I guess we have to bite this bullet, so I installed your patch into "master". Thanks, Stefan From unknown Fri Aug 15 02:03:37 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 07 May 2015 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator