How can I set timers in Emacs to trigger at certain times of day? Midnight mode adds hooks for a single "midnight" time, but I would like to create separate hooks for multiple clock times.
You can use
run-at-time to run some code at a specific time.
For example, to message "go home" every day at 5 pm:
(setq go-home-timer (run-at-time "5:00pm" (* 24 60 60) (lambda () (message "go home!"))))
You can stop it with:
You can create a hook and set it up to run at 5pm every day:
(defun end-of-work-hook nil "The hook run at the end of the day") (setq go-home-timer (run-at-time "5:00pm" (* 24 60 60) (lambda () (run-hooks 'end-of-work-hook))))
Then you add things to that hook as normal:
(add-hook 'end-of-work-hook (lambda () (message "go home!")))