GNU bug report logs - #63204
29.0.90; vc-annotate does not properly test whether a face exists

Previous Next

Package: emacs;

Reported by: Tobias Bading <tbading <at> web.de>

Date: Mon, 1 May 2023 13:16:02 UTC

Severity: normal

Found in version 29.0.90

Done: Sean Whitton <spwhitton <at> spwhitton.name>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Tobias Bading <tbading <at> web.de>
To: 63204 <at> debbugs.gnu.org
Subject: bug#63204: 29.0.90; vc-annotate does not properly test whether a face exits
Date: Mon, 1 May 2023 15:15:44 +0200
1. emacs -Q

2. Imagine that in a previous Emacs session you have copied a string with
   text properties from a buffer in vc-annotate-mode, maybe also searched
   for it somewhere. IOW, your ~/.emacs.d/.emacs.desktop file may contain
   something like this:

   (setq some-search-ring-or-whatever
         '(#("heisenbug" 0 9 (face vc-annotate-face-CCCCFF))))

   Evaluate this expression to simulate a desktop-read of such a previous
   session.

3. Open lisp/vc/vc-annotate.el from the Git branch emacs-29.

4. C-x v g (vc-annotate)

5. There are lines with white background caused by the use of undefined face
   vc-annotate-face-CCCCFF. C-h e should contain:

   Invalid face reference: vc-annotate-face-CCCCFF

   If for whatever reason you don’t see these bad lines, use C-u C-x = to
   see what face a line uses and repeat these steps with this face instead
   of vc-annotate-face-CCCCFF.


This can be fixed with:

diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
index 70057a6aac..ae8db021ad 100644
--- a/lisp/vc/vc-annotate.el
+++ b/lisp/vc/vc-annotate.el
@@ -724,7 +724,9 @@ vc-annotate-lines
                                       (substring (cdr color) 1)
                                     (cdr color))))
                ;; Make the face if not done.
-               (face (or (intern-soft face-name)
+               (face (or (let ((sym (intern-soft face-name)))
+                           (if (facep sym)
+                               sym))
                          (let ((tmp-face (make-face (intern face-name))))
                            (set-face-extend tmp-face t)
                            (cond

My Emacs Lisp isn’t that great so please feel free to improve this code
if needed. The important part is that (intern-soft face-name) is not
sufficient to check whether a face exists.


This bug report was last modified 132 days ago.

Previous Next


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