]> git.eshelyaron.com Git - emacs.git/commitdiff
Reuse calendar temporary faces
authorManuel Giraud <manuel@ledu-giraud.fr>
Thu, 24 Apr 2025 14:27:33 +0000 (16:27 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 27 Apr 2025 13:28:32 +0000 (15:28 +0200)
* lisp/calendar/calendar.el (calendar-make-temp-face): Reuse
temporary face produced by calendar.  (Bug#78036)

(cherry picked from commit af22c9292df85df9421ef11cadccb656a4bf3d7f)

lisp/calendar/calendar.el

index 79f16800c12638f11c44cda5e1b388234c3d8bd6..c9924aefd2987be53ed562c066767ddb23b51510 100644 (file)
@@ -2513,9 +2513,9 @@ ATTRLIST is a list with elements of the form :face face :foreground color."
     (if (not faceinfo)
         ;; No attributes to apply, so just use an existing-face.
         face
-      ;; FIXME should we be using numbered temp-faces, reusing where poss?
+      ;; Compute temp face name.
       (setq temp-face
-            (make-symbol
+            (intern
              (concat ":caltemp"
                      (mapconcat (lambda (sym)
                                   (cond
@@ -2523,10 +2523,12 @@ ATTRLIST is a list with elements of the form :face face :foreground color."
                                    ((numberp sym) (number-to-string sym))
                                    (t sym)))
                                 attrlist ""))))
-      (make-face temp-face)
-      (copy-face face temp-face)
-      ;; Apply the font aspects.
-      (apply #'set-face-attribute temp-face nil (nreverse faceinfo))
+      ;; Create this new face if it does not already exist.
+      (unless (member temp-face (face-list))
+        (make-face temp-face)
+        (copy-face face temp-face)
+        ;; Apply the font aspects.
+        (apply #'set-face-attribute temp-face nil (nreverse faceinfo)))
       temp-face)))
 
 (defun calendar-mark-visible-date (date &optional mark)