Subject: bug#78036: closed (Re: bug#78036: [PATCH] Reuse calendar temporary face)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 26 Apr 2025 14:07:02 +0000

Your bug report

#78036: [PATCH] Reuse calendar temporary face

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
78036: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78036
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#78036: [PATCH] Reuse calendar temporary face
From: Eli Zaretskii <[email-masked]>
To: Manuel Giraud <[email-masked]>
Cc: [email-masked]
Date: Sat, 26 Apr 2025 17:06:14 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Manuel Giraud <[email-masked]>
> Date: Thu, 24 Apr 2025 16:36:42 +0200
> 
> As suggested by the comment, this patch tries to reuse "temporary" faces
> created by calendar.el.  Without this, if you have a diary entry like:
> 
> --8<---------------cut here---------------start------------->8---
> %%(diary-block 4 1 2025 4 30 2025 '(:background "lightgrey")) A busy month
> --8<---------------cut here---------------end--------------->8---
> 
> Emacs will create a new face for each day in the block.

Thanks, installed on the master branch, and closing the bug.

Subject: [PATCH] Reuse calendar temporary face
From: Manuel Giraud <[email-masked]>
To: [email-masked]
Date: Thu, 24 Apr 2025 16:36:42 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

Hi,

As suggested by the comment, this patch tries to reuse "temporary" faces
created by calendar.el.  Without this, if you have a diary entry like:

--8<---------------cut here---------------start------------->8---
%%(diary-block 4 1 2025 4 30 2025 '(:background "lightgrey")) A busy month
--8<---------------cut here---------------end--------------->8---

Emacs will create a new face for each day in the block.

In GNU Emacs 31.0.50 (build 5, x86_64-unknown-openbsd7.7, X toolkit) of
 2025-04-22 built on computer
Repository revision: 871ec9615a949e967bf7d19466eb9c56ed80ff7e
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: OpenBSD computer 7.7 GENERIC.MP#626 amd64

Configured using:
 'configure CC=egcc CPPFLAGS=-I/usr/local/include
 LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs
 --bindir=/home/manuel/bin --with-x-toolkit=lucid
 --with-toolkit-scroll-bars=no --without-cairo
 --without-compress-install'

>From 4cf973bd4e57ded405aa6b8679c9f56e27f3b20a Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Thu, 24 Apr 2025 16:27:33 +0200
Subject: [PATCH] Reuse calendar temporary face

* lisp/calendar/calendar.el (calendar-make-temp-face): Reuse
temporary face produced by calendar.
---
 lisp/calendar/calendar.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 08ecd586ec1..058982647fe 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -2515,9 +2515,9 @@ calendar-make-temp-face
     (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
@@ -2525,10 +2525,12 @@ calendar-make-temp-face
                                    ((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)
-- 
2.49.0

-- 
Manuel Giraud