GNU bug report logs - #20276
24.4; diff-mode doesn't handle unified diff file headers without tabs

Previous Next

Package: emacs;

Reported by: Gustav HÃ¥llberg <gustav <at> gmail.com>

Date: Tue, 7 Apr 2015 22:35:01 UTC

Severity: normal

Found in version 24.4

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gustav HÃ¥llberg <gustav <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4; diff-mode doesn't handle unified diff file headers without tabs
Date: Wed, 8 Apr 2015 00:34:23 +0200
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]

This bug report was last modified 10 years and 98 days ago.

Previous Next


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