Subject: Re: bug#78120: 31.0.50; Calendar is not reliable with its marking

From: Manuel Giraud <[email-masked]>
Date: Wed, 07 May 2025 16:39:00 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Michael Heerdegen <[email-masked]>
>> Cc: Manuel Giraud <[email-masked]>,  [email-masked]
>> Date: Wed, 07 May 2025 00:44:33 +0200
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> > Each face has a meaning, I presume?  If one face marks a date because
>> > John Doe was born at that day, and another face marks the same date
>> > because I have an important meeting, then the latter should "win",
>> > right?
>> 
>> It depends?  If John doe is your husband, maybe he is much more
>> important and should "win".  Maybe you will have a free day at his
>> birthday anyway.
>
> While these situations are possible, I think they are quite rare in
> practice.  So while today we have this problem in all the cases, with
> the change I propose we will have it only rarely: a clear "win", IMO.
>
> I also made another suggestion: to change the default definition of
> some of the faces so that they don't all use the same face attribute.
> Then we could fix this problem even cleaner, IMO.  But no one
> responded to that suggestion, and I wonder why.
>
>> So this is a good example of how difficult this is.  It totally depends
>> on your life and your circumstances.  Also, Emacs doesn't know what an
>> "important meeting" is, and who John Doe is.
>
> We usually solve this for the most probable situation, and leave the
> rest to user customizations of the faces.  It isn't the first time we
> bump into this problem.
>
> Moreover, to reason about this in a useful way, we need a list of
> faces that could conflict and their semantics.  AFAICT, no one posted
> such a list.  So for now we are having an almost purely academic
> discussion, without even knowing how many faces could conflict in this
> way.

AFAICT, for calendar, we have diary, calendar-today, holiday and
diary-anniversary with the following default definitions:

--8<---------------cut here---------------start------------->8---
(defface calendar-today
  '((t (:underline t)))
  "Face for indicating today's date in the calendar.
See the variable `calendar-today-marker'."
  :group 'calendar-faces)

(defface diary
  '((((min-colors 88) (class color) (background light))
     :foreground "red1")
    (((class color) (background light))
     :foreground "red")
    (((min-colors 88) (class color) (background dark))
     :foreground "yellow1")
    (((class color) (background dark))
     :foreground "yellow")
    (t
     :weight bold))
  "Face for highlighting diary entries.
Used to mark diary entries in the calendar (see `diary-entry-marker'),
and to highlight the date header in the fancy diary."
  :group 'calendar-faces)

(defface holiday
  '((((class color) (background light))
     :background "pink")
    (((class color) (background dark))
     :background "chocolate4")
    (t
     :inverse-video t))
  "Face for indicating in the calendar dates that have holidays.
See `calendar-holiday-marker'."
  :group 'calendar-faces)

(defface diary-anniversary '((t :inherit font-lock-keyword-face))
  "Face used for anniversaries in the fancy diary display."
  :version "22.1"
  :group 'calendar-faces)
--8<---------------cut here---------------end--------------->8---

>From this list, I think that only diary and diary-anniversary would
conflict as they both set the foreground… but as all those faces could
be customized by a theme, we could have conflicts at a later time.  For
example: modus themes also use the foreground for holiday so it adds a
new conflict with diary and diary-anniversary.

> So I think you reject this kind of solution too early.
>
>> And the same is true for other sources of highlighting.  Are holidays
>> important?  Depends on how religious you are etc.
>
> If indeed you are right, and the importance is frequently inverted
> (and I'm not yet sure you are right), then we could provide user
> options for resolving the conflicts.  But such user options should not
> be overlay priorities, but something like "face importance", from
> which the code should derive the priorities.  Asking users to provide
> priorities themselves is not user-friendly, for the reasons I
> explained up-thread.

Yes, we could have a set of diary faces like the set of
gnus-group-mail-* faces, for example.
-- 
Manuel Giraud