help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toggle appointment notification


From: Emanuel Berg
Subject: Re: Toggle appointment notification
Date: Tue, 01 Dec 2020 05:56:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

pietru wrote:

> Want to toggle between enable and disable appointment
> notification and have put a defun as so below. I reckon that
> both appt-activate and appt-check are needed but not absolutely
> aware of what and how they activate things for appointments.
>
> What would be a right approach to toggle between enable and
> disable using a single key-sequence for my case here?

For a single key to toggle, branch on the current state!

One approach would be - from the appt source [1] I see that
`appt-activate', when used to INactivate, does this

  (setq appt-timer nil)

and then doesn't reset it. So maybe that can be used as a state
variable, if there isn't a particular one for the purpose?

> (defun diary-appt-ntf (n)
>    "Switches diary appointment notification."
>
>    (appt-activate n)  ; Activates diary appointment notification
>
>    (if (< n 1)
>      (appt-check 1)    ; Checks appointments and updates reminders.
>      (appt-check nil)) ; Disables appt-check
> )

Looks good, so you know Elisp, alright then 1) find a variable or
buffer (exists/doesn't exist) to express running or don't run,
2) write a function that branches on that and then calls the
above function accordingly, 3) bind a key to the branch function.

Good luck, and do ask again/tell how you solved it :)


[1] /usr/local/share/emacs/28.0.50/lisp/calendar/appt.el.gz

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]