* interaction of fontified calendar entries and org-read-date
@ 2024-02-13 15:45 John Kitchin
2024-02-14 15:04 ` Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: John Kitchin @ 2024-02-13 15:45 UTC (permalink / raw)
To: Emacs Orgmode
[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]
I am trying to debug something in org-read-date.
If I run this code:
(let* ((mark-calendar (lambda ()
(calendar-mark-visible-date
(read (format-time-string "(%m %d %Y)"))
'font-lock-warning-face)))
(calendar-today-visible-hook))
(add-hook 'calendar-today-visible-hook
mark-calendar)
(org-read-date))
I get a little calendar that pops up, today is marked red, and there is a
red square on it. I can use shift arrows to move the red box around so i
can see what day is selected.
This slightly different code (differs only in assigning an anonymous face
instead of an actual face doesn't do that exactly. Today is still marked
red, but it is no longer selected with the inverse square. Neighboring days
do get the red square, but not "today".
(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)
(org-read-date))
This is somewhat of an xy kind of question. I am writing code that sets the
color of a day based on the number of tasks due that day, so I can't
exactly define faces for all of those, and I was using the anonymous face
for that. However, in doing that I lost the inverse video selection cursor
so it is hard to tell where the cursor actually is.
I assume that somewhere the cursor is getting an inverse-video attribute
from the face that isn't present in the anonymous face, but I haven't been
able to figure out where that comes in.
Any suggestions for either how to fix this, or another approach to coloring
the days in the calendar?
--
John
-----------------------------------
Professor John Kitchin (he/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
https://kitchingroup.cheme.cmu.edu
https://pointbreezepubs.gumroad.com/ pycse bookstore
[-- Attachment #2: Type: text/html, Size: 2661 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: interaction of fontified calendar entries and org-read-date
2024-02-13 15:45 interaction of fontified calendar entries and org-read-date John Kitchin
@ 2024-02-14 15:04 ` Ihor Radchenko
2024-02-14 18:13 ` John Kitchin
0 siblings, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2024-02-14 15:04 UTC (permalink / raw)
To: John Kitchin; +Cc: Emacs Orgmode
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> This slightly different code (differs only in assigning an anonymous face
> instead of an actual face doesn't do that exactly. Today is still marked
> red, but it is no longer selected with the inverse square. Neighboring days
> do get the red square, but not "today".
>
> (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)
> (org-read-date))
That's because cursor background becomes the same as text foreground and
Emacs prevents the clash.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: interaction of fontified calendar entries and org-read-date
2024-02-14 15:04 ` Ihor Radchenko
@ 2024-02-14 18:13 ` John Kitchin
2024-02-14 20:18 ` Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: John Kitchin @ 2024-02-14 18:13 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Emacs Orgmode
[-- Attachment #1: Type: text/plain, Size: 1417 bytes --]
why does it work with a face though?
On Wed, Feb 14, 2024 at 10:00 AM Ihor Radchenko <yantar92@posteo.net> wrote:
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
> > This slightly different code (differs only in assigning an anonymous face
> > instead of an actual face doesn't do that exactly. Today is still marked
> > red, but it is no longer selected with the inverse square. Neighboring
> days
> > do get the red square, but not "today".
> >
> > (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)
> > (org-read-date))
>
> That's because cursor background becomes the same as text foreground and
> Emacs prevents the clash.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>
--
John
-----------------------------------
Professor John Kitchin (he/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
https://kitchingroup.cheme.cmu.edu
https://pointbreezepubs.gumroad.com/ pycse bookstore
[-- Attachment #2: Type: text/html, Size: 2439 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: interaction of fontified calendar entries and org-read-date
2024-02-14 18:13 ` John Kitchin
@ 2024-02-14 20:18 ` Ihor Radchenko
2024-02-15 1:17 ` John Kitchin
0 siblings, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2024-02-14 20:18 UTC (permalink / raw)
To: John Kitchin; +Cc: Emacs Orgmode
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> why does it work with a face though?
It really does. That's confusing. And proves that Emacs is smart enough
to invert cursor color in some situations.
My only guess is that `calendar-make-temp-face' is using `make-face'
incorrectly. I guess that
Do not call this directly from Lisp code; use `defface' instead.
in `make-face' docstring is there for a reason.
Maybe report this as Emacs bug in calendar.el?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: interaction of fontified calendar entries and org-read-date
2024-02-14 20:18 ` Ihor Radchenko
@ 2024-02-15 1:17 ` John Kitchin
2024-02-21 11:21 ` Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: John Kitchin @ 2024-02-15 1:17 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Emacs Orgmode
[-- Attachment #1: Type: text/plain, Size: 2741 bytes --]
Thanks for the tip on `calendar-make-temp-face'. It gets even weirder now.
If I use a face, that function does not even seem to get called, so it
seems to work.
If I use the anonymous face though, it does get called, and I see the
inconsistent behavior.
However, if I edebug `calendar-make-temp-face' and step through each line,
then it works the same as using a face. And, after that it seems to work
most of the time.
"Do not call this directly from Lisp code; use ‘defface’ instead." seems
like a weird message. Where else would one use this?
Anyway, thanks again, I have stumbled on a solution, which is to modify
`calendar-mark-visible-date' so it does not use `calendar-make-temp-face' .
It is a small change of:
(t ; attr list
(overlay-put
(make-overlay (1- (point)) (1+ (point))) 'face
(calendar-make-temp-face mark)))
to
(t ; attr list
(overlay-put
(make-overlay (1- (point)) (1+ (point))) 'face
mark))
That seems to work.
A simpler way though is to just put the overlays on manually in the hook,
e.g.
(let* ((mark-calendar (lambda ()
;; Goto today
(save-excursion
(calendar-cursor-to-visible-date (read (format-time-string "(%m %d %Y)")))
(overlay-put
(make-overlay (1- (point)) (1+ (point))) 'face
(list :foreground "blue" :weight 'bold)))))
(calendar-today-visible-hook))
(add-hook 'calendar-today-visible-hook
mark-calendar)
(org-read-date))
I can live with that solution. Thanks for the assist!
On Wed, Feb 14, 2024 at 3:14 PM Ihor Radchenko <yantar92@posteo.net> wrote:
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
> > why does it work with a face though?
>
> It really does. That's confusing. And proves that Emacs is smart enough
> to invert cursor color in some situations.
>
> My only guess is that `calendar-make-temp-face' is using `make-face'
> incorrectly. I guess that
>
> Do not call this directly from Lisp code; use `defface' instead.
>
> in `make-face' docstring is there for a reason.
> Maybe report this as Emacs bug in calendar.el?
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>
--
John
-----------------------------------
Professor John Kitchin (he/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
https://kitchingroup.cheme.cmu.edu
https://pointbreezepubs.gumroad.com/ pycse bookstore
[-- Attachment #2: Type: text/html, Size: 4181 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: interaction of fontified calendar entries and org-read-date
2024-02-15 1:17 ` John Kitchin
@ 2024-02-21 11:21 ` Ihor Radchenko
2024-02-21 14:59 ` John Kitchin
0 siblings, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2024-02-21 11:21 UTC (permalink / raw)
To: John Kitchin; +Cc: Emacs Orgmode
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> However, if I edebug `calendar-make-temp-face' and step through each line,
> then it works the same as using a face. And, after that it seems to work
> most of the time.
It turned out that the problem is caused by interaction between Org
mode's overlay and calendar.el's overlay. They have the same priority,
so the order they are applied depends on subtle details of the code and
on when redisplay occurs.
That's why edebug yielded different results.
See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69271
I fixed this subtle issue on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=67d937248
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: interaction of fontified calendar entries and org-read-date
2024-02-21 11:21 ` Ihor Radchenko
@ 2024-02-21 14:59 ` John Kitchin
0 siblings, 0 replies; 7+ messages in thread
From: John Kitchin @ 2024-02-21 14:59 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Emacs Orgmode
[-- Attachment #1: Type: text/plain, Size: 1389 bytes --]
Awesome work! Thanks for tracking that down!
On Wed, Feb 21, 2024 at 6:17 AM Ihor Radchenko <yantar92@posteo.net> wrote:
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
> > However, if I edebug `calendar-make-temp-face' and step through each
> line,
> > then it works the same as using a face. And, after that it seems to work
> > most of the time.
>
> It turned out that the problem is caused by interaction between Org
> mode's overlay and calendar.el's overlay. They have the same priority,
> so the order they are applied depends on subtle details of the code and
> on when redisplay occurs.
> That's why edebug yielded different results.
>
> See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69271
>
> I fixed this subtle issue on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=67d937248
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>
--
John
-----------------------------------
Professor John Kitchin (he/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
https://kitchingroup.cheme.cmu.edu
https://pointbreezepubs.gumroad.com/ pycse bookstore
[-- Attachment #2: Type: text/html, Size: 2559 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-02-21 19:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-13 15:45 interaction of fontified calendar entries and org-read-date John Kitchin
2024-02-14 15:04 ` Ihor Radchenko
2024-02-14 18:13 ` John Kitchin
2024-02-14 20:18 ` Ihor Radchenko
2024-02-15 1:17 ` John Kitchin
2024-02-21 11:21 ` Ihor Radchenko
2024-02-21 14:59 ` John Kitchin
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.