I understand in general about idle timers in emacs, but I'm having trouble figuring out how to do the following ...
I want to set an
is-idle variable to
t when emacs is in an idle state, and I want that variable to set to
nil when emacs is not idle.
Why do I want this? It's because I have written signal handlers for sigusr1 and sigusr2 which get invoked when my emacs process receives either of these external signals. I want the handlers not to run if emacs doesn't happen to be idle at the moment that the sigusr1 or sigusr2 signals are received.
In other words, I want my signal handler to look like this:
(when is-idle ;; do all the sigusr1/sigusr2 processing ;; ... etc. ... )
I haven't figured out how to manage this with an idle timer, nor with any other emacs facilities.
Instead of a variable,
is-idle could be a function. I don't really care which it is. I just want to know at the moment that the signal is received as to whether my emacs session is idle or not.
Thanks in advance.
I came across the
(current-idle-time) function. Here's its doc string ...
Return the current length of Emacs idleness, or nil. The value when Emacs is idle is a list of four integers (HIGH LOW USEC PSEC) in the same style as (current-time). The value when Emacs is not idle is nil. PSEC is a multiple of the system clock resolution.
I'm going to do some investigation as to whether this function will provide what I'm looking for, and I'll report back.