Traveling with my kid I had some medication to give him the other night. I didn’t have an alarm clock with me, only my laptop computer. Into the Windows system I found nothing suited to help me gain some rest while waking up again at 3:00 am. I wished Emacs could help, and it certainly didn’t disappoint me once more. I found a simple alarm clock coded by Mathias Dahl here . Great!, I only had to tweak it a little by adding a sound load enough to ring me at the desired time. I picked a rooster sing, which I had collected a while ago when my child was getting to know farm animals. I put a loop around to repeat it a few times so to guarantee the awakening.
Anyways, for what is worth, here goes the cool little snippet:
(defvar alarm-clock-timer nil "Keep timer so that the user can cancel the alarm") (defun alarm-clock-message (text) "The actual alarm action" (progn (let((i 0)) (while (< i 3) (play-sound-file "c:/web/sounds/rooster.wav") (setq i (1+ i))) (message-box text)))) (defun alarm-clock () "Set an alarm. The time format is the same accepted by `run-at-time'. For example \"11:30am\"." (interactive) (let ((time (read-string "Time: ")) (text (read-string "Alarm message: "))) (progn (setq alarm-clock-timer (run-at-time time nil 'alarm-clock-message text))))) (defun alarm-clock-cancel () "Cancel the alarm clock" (interactive) (cancel-timer alarm-clock-timer))
UPDATE: see the small variation presented inside a comment for changing times on different days.