GNU bug report logs - #54034
29.0.50; Diff prettify broken for empty files

Previous Next

Package: emacs;

Reported by: Matthias Meulien <orontee <at> gmail.com>

Date: Thu, 17 Feb 2022 07:49:02 UTC

Severity: normal

Found in version 29.0.50

Full log


View this message in rfc822 format

From: Matthias Meulien <orontee <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 54034 <at> debbugs.gnu.org
Subject: bug#54034: 29.0.50; Diff prettify broken for empty files
Date: Thu, 07 Apr 2022 09:11:08 +0200
[Message part 1 (text/plain, inline)]
Here is an updated patch with a small display improvement: File name
doesn't appear in the middle of the line anymore.

[Capture d’écran du 2022-04-07 09-07-46.png (image/png, inline)]
[0001-Display-file-mode-information-when-diff-font-lock-pr.patch (text/x-diff, inline)]
From 35ae0c0d343cc530cb79ee08fbedd641beb212ee Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee <at> gmail.com>
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


This bug report was last modified 2 years and 349 days ago.

Previous Next


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