"Stefan van der Walt" <stef...@berkeley.edu> writes:
>>> Could we reset the variable *after* the hooks are run instead, so that they 
>>> can access the timer value?
>>
>> Yes, that would make sense. See the attached tentative patch.
>
> Thanks, Ihor! That patch looks great. In the description: `ran` -> `run`.

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=9368db471b

>>> 2. I have a custom notification for when the timer is done, installed via 
>>> the done hook. I would like to suppress the existing notification, but 
>>> there seems to be no option to do so. Would it make sense to provide a 
>>> mechanism to override/silence the notification?
>>
>> We can do it.
>> One would need to implement analogues to
>> org-timer-start/stop/pause/continue/set/done-hook that will hold what
>> Org does by default at that point (turn on/off mode line, play sound,
>> print message, etc). Something like
>> org-timer-start/stop/...-default-hook.
>
> That would be a good generic solution. In my case, if I can suppress 
> org-show-notification, it'd be enough. Here's what I tried (but it didn't 
> work):
>
>   (defun stefanv/suppress-org-notify (orig-fun &rest args)
>     (cl-letf (
>                ((symbol-function 'org-show-notification) (lambda (&rest _) 
> (ignore)))
>              )
>       (apply orig-fun args)))
>   (advice-add 'org-timer--run-countdown-timer :around 
> #'stefanv/suppress-org-notify)

Your solution won't work because `org-timer--run-countdown-timer' does
not actually execute `org-show-notification'. It just sets up a timer to
call that function later, outside the dynamic scope you are setting up
with `cl-letf'.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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>

Reply via email to