From: Ihor Radchenko <yantar92@posteo.net>
To: Stefan van der Walt <stefanv@berkeley.edu>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-timer: let done hook access time, allow silencing notification
Date: Sun, 12 Jan 2025 08:11:48 +0000 [thread overview]
Message-ID: <874j2478or.fsf@localhost> (raw)
In-Reply-To: <52611558-9247-44c2-a51c-5f0dd8662fe1@app.fastmail.com>
"Stefan van der Walt" <stefanv@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>
prev parent reply other threads:[~2025-01-12 8:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 20:09 org-timer: let done hook access time, allow silencing notification Stefan van der Walt
2025-01-11 17:17 ` Ihor Radchenko
2025-01-12 5:56 ` Stefan van der Walt
2025-01-12 8:11 ` Ihor Radchenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874j2478or.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=stefanv@berkeley.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).