reddit / emacs

Help with Elisp for Timer

Hercislife23 · 2022-10-19 00:58
I basically want to create a very basic elisp function that calls the `org-timer-set-timer` to set a timer for 25 minutes, and then when that finishes it starts a second timer that is for 5 minutes. The code below is my attempt at a function to create a timer, but how do I have it start the second timer when the first one finishes? Thank you for the help! `(defun start-timer ()` `(org-timer-set-timer "0:25:00"))`
lj-read-it · 2022-10-19 01:41
Unless you're doing this specifically to practice Elisp, I think just using the ```org-pomodoro``` package would be easier...
globalcandyamnesia · 2022-10-19 01:54
There is a hook for when the timer reaches 0. You could use that to start a new timer. You'd have to set a variable to make sure you don't start an infinite loop.
Hercislife23 · 2022-10-19 01:54
It is just to practice elisp, yeah.
arthurno1 · 2022-10-19 14:54
> I basically want to create a very basic elisp function that calls the org-timer-set-timer to set a timer for 25 minutes, and then when that finishes it starts a second timer that is for 5 minutes. Since you want to learn (practice) elisp as you say in the other comment, I'll just outline a little: You don't want here org-timer-set-timer. This is an interactive function (a command) and is meant to be used with M-x so you can choose a timer. If you gonna call it from lisp, use 'call-interactively'. But you don't want to use that function at all here, you are looking for 'run-at-time' or 'run-with-timer' alternatively 'with-timeout'. You should check the documentation for all of those in [the manual](https://www.gnu.org/software/emacs/manual/html_node/elisp/Timers.html). In the function you call in timer, you can set up an idle-timer to run when the old one has finished. One way would be to run an idle timer at certain interval and check if the other timer has finished.