4 (defvar hanoi-break-interval
(* 60 30)
5 "*Number of seconds between Hanoi breaks.")
7 (add-hook 'post-command-hook
'hanoi-break-check t
)
9 (defvar hanoi-break-p nil
10 "Non-nil if we need a Hanoi break real soon now.")
12 (defun hanoi-break-check ()
13 "Take a Hanoi break if the time has come."
14 (and (not (input-pending-p))
16 (setq hanoi-break-p nil
))
21 "Take a Hanoi break, son."
23 (save-window-excursion
24 (eval (condition-case error
25 (if (not (yes-or-no-p "Take a break now? "))
26 '(hanoi-break-schedule 60) ; Bug him again in one minute.
28 (if (eq (selected-window) (minibuffer-window))
30 (delete-other-windows)
31 (scroll-right (window-width))
32 ;; Send him on his way.
33 (message "Take a break, son.")
34 (if (get-buffer "*Hanoi*")
35 (kill-buffer "*Hanoi*"))
38 (hanoi (/ (window-width) 8))
39 ;; Wait for him to come back.
41 (kill-buffer "*Hanoi*"))
43 '(hanoi-break-schedule)) ; Schedule next break.
44 (quit '(hanoi-break-schedule 60)) ; Bug him again in one minute.
49 (defun hanoi-break-schedule (&optional time
)
50 "Schedule a break for ARG seconds from now (default: hanoi-break-interval)."
51 (interactive (list (and current-prefix-arg
52 (prefix-numeric-value current-prefix-arg
))))
53 (or time
(setq time hanoi-break-interval
))
54 (run-at-time time nil
'hanoi-break-soon
))
56 (defun hanoi-break-soon ()
57 "Take a Hanoi break very soon."
58 (setq hanoi-break-p t
))
60 (defun cancel-hanoi-break ()
61 "Cancel scheduled Hanoi breaks."
63 (cancel-function-timers 'hanoi-break-soon
))
65 (provide 'hanoi-break
)