I would like to start the countdown function, (org-timer-set-timer)
(C-c C-x ;
), and trigger an action once the timer is over.
Any hints on how this could be achieved?
Shall I just use the run-at-time
function instead? (This wouldn't show the countdown timer in the mode bar, but I guess I could survive).
2 Answers
'hooks' are variables to which you can add functions that will get automatically called, so that you don't need to go changing the original source code to get a behaviour change. This particular one is not documented, apart from its name. You can use it by doing eg:
(defun my-org-timer-hook ()
(message "My timer done"))
(add-hook 'org-timer-done-hook 'my-org-timer-hook)
See (emacs) Hooks for a fuller explanation.
-
C-h v org-timer-done-hook
says "Hook run after countdown timer reaches zero." so strictly speaking, it is documented. Do you mean "documented in the manual"?– NickDSep 21, 2018 at 18:25 -
I somehow missed that, even though I was looking at org-timer.el. Documentation in the manual would be nice.– rpluimSep 21, 2018 at 20:57
-
I doubt that it is going to be documented in the manual: it's a bit too generic, so the general emacs hook documentation that you linked to probably covers it.– NickDSep 21, 2018 at 21:52
Thanks for this... I have extended your solution with an example of playing a sound file with afplay
on MacOS when org-timer ends:
; play sound when org-timer completes
(add-hook 'org-timer-done-hook (lambda () (interactive)
(shell-command "afplay $HOME/Downloads/ShipsBell.wav")))
Hope this proves useful for someone on the Internetz
org-timer-done-hook
?