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

From: Matthias Meulien <[email-masked]>
Date: Thu, 07 Apr 2022 09:11:08 +0200

Here is an updated patch with a small display improvement: File name
doesn't appear in the middle of the line anymore.

>From 35ae0c0d343cc530cb79ee08fbedd641beb212ee Mon Sep 17 00:00:00 2001
From: Matthias Meulien <[email-masked]>
Date: Thu, 7 Apr 2022 00:47:31 +0200
Subject: [PATCH] Display file mode information when diff font lock prettify
 enabled

* lisp/vc/diff-mode.el (diff--font-lock-prettify): Make regexp capture
file mode information.
---
 lisp/vc/diff-mode.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 251d3dc090..c6409d1677 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2661,12 +2661,14 @@ diff--font-lock-prettify
                                   (match-beginning 5)
                                   (not (match-beginning 3)))
                         " empty")))
-              (filemode (if (match-beginning 10)
-                            (concat " file with mode " (match-string 10) "  ")
-                          " file  "))
-              (modechanged (when (and (match-beginning 8) (match-beginning 9))
-                             (concat " mode changed from "
-                                     (match-string 8) " to " (match-string 9)))))
+              (filemode
+               (cond
+                ((match-beginning 10)
+                 (concat " file with mode " (match-string 10) "  "))
+                ((and (match-beginning 8) (match-beginning 9))
+                 (concat " file (mode changed from "
+                         (match-string 8) " to " (match-string 9) ")  "))
+                (t " file  "))))
           (add-text-properties
            (match-beginning 0) (1- (match-end 0))
            (list 'display
@@ -2680,7 +2682,7 @@ diff--font-lock-prettify
                    ((null (match-string 2))
                     (concat "Deleted" kind filemode oldfile))
                    (t
-                    (concat "Modified" kind " file  " oldfile modechanged)))
+                    (concat "Modified" kind filemode oldfile)))
                   'face '(diff-file-header diff-header))
                  'font-lock-multiline t))))))
   nil)
-- 
2.30.2