bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#54034: 29.0.50; Diff prettify broken for empty files


From: Stefan Monnier
Subject: bug#54034: 29.0.50; Diff prettify broken for empty files
Date: Wed, 29 Jun 2022 11:47:33 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Basil L. Contovounesios [2022-06-24 01:36:15] wrote:
> I think this gave rise to the following regression in the header when
> diff-font-lock-prettify is enabled:
>
> 0. emacs -Q
> 1. M-x diff-buffers RET RET RET
>    [ Header now comprises 'diff -u ...'. ]
> 2. (setq diff-font-lock-prettify t) C-x C-e
> 3. C-x o g
>    [ Header is now 'Deleted file'. ]
>
> It's not particularly jarring to see a header like that when diffing
> non-file-visiting buffers, but more importantly the same header appears
> when diffing any regular files via M-x diff.

[ It'd have been better to file a new bug report for this one, FWIW.  ]

I installed the patch below, which seems safe, but is probably
not optimal.  Matthias?


        Stefan


diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 0fd67422d55..3f3e503a3f3 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2682,7 +2682,17 @@ diff--font-lock-prettify
                    ((and (null (match-string 4)) (match-string 5))
                     (concat "New " kind filemode newfile))
                    ((null (match-string 2))
-                    (concat "Deleted" kind filemode oldfile))
+                    ;; We used to use
+                    ;;     (concat "Deleted" kind filemode oldfile)
+                    ;; here but that misfires for `diff-buffers'
+                    ;; (see 24 Jun 2022 message in bug#54034).
+                    ;; AFAIK if (match-string 2) is nil then so is
+                    ;; (match-string 1), so "Deleted" doesn't sound right,
+                    ;; so better just let the header in plain sight for now.
+                    ;; FIXME: `diff-buffers' should maybe try to better
+                    ;; mimic Git's format with "a/" and "b/" so prettification
+                    ;; can "just work!"
+                    nil)
                    (t
                     (concat "Modified" kind filemode oldfile)))
                   'face '(diff-file-header diff-header))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]