Gnus, being larger than any program ever written (allegedly), does lots of strange stuff that you may wish to have done while you're not present. For instance, you may want it to check for new mail once in a while. Or you may want it to close down all connections to all servers when you leave Emacs idle. And stuff like that.
Gnus will let you do stuff like that by defining various handlers. Each handler consists of three elements: A function, a time, and an idle parameter.
Here's an example of a handler that closes connections when Emacs has been idle for thirty minutes:
(gnus-demon-close-connections nil 30)
Here's a handler that scans for PGP headers every hour when Emacs is idle:
(gnus-demon-scan-pgp 60 t)
This time parameter and than idle parameter work together
in a strange, but wonderful fashion. Basically, if idle is
nil
, then the function will be called every time minutes.
If idle is t
, then the function will be called after
time minutes only if Emacs is idle. So if Emacs is never idle,
the function will never be called. But once Emacs goes idle, the
function will be called every time minutes.
If idle is a number and time is a number, the function will be called every time minutes only when Emacs has been idle for idle minutes.
If idle is a number and time is nil
, the function
will be called once every time Emacs has been idle for idle
minutes.
And if time is a string, it should look like `07:31
', and
the function will then be called once every day somewhere near that
time. Modified by the idle parameter, of course.
(When I say ``minute'' here, I really mean gnus-demon-timestep
seconds. This is 60 by default. If you change that variable,
all the timings in the handlers will be affected.)
To set the whole thing in motion, though, you have to set
gnus-use-demon
to t
.
So, if you want to add a handler, you could put something like this in
your `.gnus
' file:
(gnus-demon-add-handler 'gnus-demon-close-connections 30 t)
Some ready-made functions to do this have been created:
gnus-demon-add-nocem
, gnus-demon-add-disconnection
,
gnus-demon-add-nntp-close-connection
,
gnus-demon-add-scan-timestamps
, gnus-demon-add-rescan
, and
gnus-demon-add-scanmail
. Just put those functions in your
`.gnus
' if you want those abilities.
If you add handlers to gnus-demon-handlers
directly, you should
run gnus-demon-init
to make the changes take hold. To cancel all
daemons, you can use the gnus-demon-cancel
function.
Note that adding daemons can be pretty naughty if you over do it. Adding functions that scan all news and mail from all servers every two seconds is a sure-fire way of getting booted off any respectable system. So behave.
Buttons Various NoCeM