all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: 69271@debbugs.gnu.org
Subject: bug#69271: 30.0.50; Strange interaction between :inverse-video overlay face and calendar today face
Date: Tue, 20 Feb 2024 18:08:14 +0200	[thread overview]
Message-ID: <86jzmznmoh.fsf@gnu.org> (raw)
In-Reply-To: <875xykfy6z.fsf@localhost> (message from Ihor Radchenko on Mon, 19 Feb 2024 12:14:28 +0000)

> From: Ihor Radchenko <yantar92@posteo.net>
> Date: Mon, 19 Feb 2024 12:14:28 +0000
> 
> 1. emacs -Q
> 2. Insert the following code into *scratch* buffer
> 
> 
> (defface yant/test '((t :foreground "red" :weight bold)) "")
> (defface yant/test-inv '((t :foreground "red"  :inverse-video t)) "")
> (require 'calendar)
> 
> ;; (dotimes (_ 5)
> ;;   (let* ((mark-calendar
> ;; 	  (lambda ()
> ;; 	    (calendar-mark-visible-date
> ;; 	     (read (format-time-string "(%m %d %Y)"))
> ;; 	     'yant/test)))
> ;; 	 (calendar-today-visible-hook))
> ;;     (add-hook 'calendar-today-visible-hook mark-calendar)
> ;;     (calendar)
> ;;     (setq cursor-type nil)
> ;;     (let ((ov (make-overlay (1- (point)) (1+ (point)))))
> ;;       (overlay-put ov 'face 'yant/test-inv)))
> ;;   (read-char "Observe overlay obeying inverse-video. Press any key")
> ;;   (kill-buffer calendar-buffer))
> (dotimes (_ 50)
>   (let* ((mark-calendar
> 	  (lambda ()
> 	    (calendar-mark-visible-date
> 	     (read (format-time-string "(%m %d %Y)"))
> 	     (list :foreground "red" :weight 'bold))))
> 	 (calendar-today-visible-hook))
>     (add-hook 'calendar-today-visible-hook mark-calendar)
>     (calendar)
>     (setq cursor-type nil)
>     (let ((ov (make-overlay (1- (point)) (1+ (point)))))
>       (overlay-put ov 'face 'yant/test-inv)))
>   (read-char "Observe overlay sometimes *not* obeying inverse-video. Press any key")
>   (kill-buffer calendar-buffer))
> 
> 3. M-x eval-buffer <RET>
> 4. Observe today date in the calendar fontified inconsistently as the
>    code is executed multiple times.

This code places two overlays on the same text, with each overlay
defining a foreground color.  So which one "wins" is basically random,
unless you give each overlay a priority to make that deterministic.

I tried a simpler recipe:

  emacs -Q
  M-x load-library RET calendar RET
  C-x b foo RET
  C-u 30 a RET
  M-: (defface yant/test-inv '((t :foreground "red"  :inverse-video t)) "") RET
  M-: (setq ov1 (make-overlay 24 26)) RET
  M-: (overlay-put ov1 'face (calendar-make-temp-face (list :foreground "red" :weight 'bold))) RET
  M-: (setq ov2 (make-overlay 24 26)) RET
  M-: (overlay-put ov2 'face 'yant/test-inv) RET

This produced text with red background, according to the yant/test-inv
face.  But if you define the overlays in the opposite order, you get
the red bold foreground instead.  If you now give each overlay a
priority, you can control which face shows: the one whose overlay has
the higher priority.

Maybe I'm missing something, but I see no bug here.





  reply	other threads:[~2024-02-20 16:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19 12:14 bug#69271: 30.0.50; Strange interaction between :inverse-video overlay face and calendar today face Ihor Radchenko
2024-02-20 16:08 ` Eli Zaretskii [this message]
2024-02-21 11:18   ` Ihor Radchenko
2024-02-21 12:05     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86jzmznmoh.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=69271@debbugs.gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.