Subject: Re: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake

From: Andrew Cohen <[email-masked]>
Date: Wed, 05 Feb 2025 21:27:13 +0800

>>>>> "AC" == Andrew Cohen <[email-masked]> writes:

[...]

    AC> So how exactly do I add a new sleep-event to the C source? I
    AC> tried copying how its done for dbus-event in keyboard.c and
    AC> termhooks.h (I'm only trying to create such an event in lisp so
    AC> I didn't worry about generating such an event in C). Is this
    AC> right? And do I always have to install the handler in the global
    AC> keymap (just to test this I tried pushing an existing dbus-event
    AC> onto unread-command-events, and also get "dbus-event is
    AC> undefined" unless I install a handler on the global keymap. So
    AC> it seems that I do. I also notice that other special events,
    AC> like delete-frame, have handlers installed in both the global
    AC> keymap and the special-event-map).

And maybe answering my own questions:

According the the elisp manual special events "cannot be unread with
‘unread-command-events’". Not sure exactly what this means (and I
haven't yet read the code to figure it out) but it certainly appears
that special events can't trigger a function bound in special-event-map
by pushing an event onto unread-command-events. But that's probably OK,
since we can /also/ bind the handler to the special event in the global
keymap, as is done for several of the existing special events
(delete-frame, make-frame-visible, iconify-frame). Then we can trigger
the event directly in C by generating the special event, or
synthetically in Lisp by pushing onto unread-command-events. 

I'll assume that this is OK unless I hear otherwise and make changes to
the package accordingly.

Best,
Andy
-- 
Andrew Cohen