annotate lisp/type-break.el @ 6814:531d6d07096a

(main): Fix typo in prev. change.
author Richard M. Stallman <rms@gnu.org>
date Tue, 12 Apr 1994 01:33:57 +0000
parents 454dc146502d
children 5ecef3b02f2d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5939
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1 (require 'timer)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
2
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
3 ;;;###autoload
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
4 (defvar hanoi-break-interval (* 60 30)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
5 "*Number of seconds between Hanoi breaks.")
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
6
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
7 (add-hook 'post-command-hook 'hanoi-break-check t)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
8
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
9 (defvar hanoi-break-p nil
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
10 "Non-nil if we need a Hanoi break real soon now.")
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
11
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
12 (defun hanoi-break-check ()
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
13 "Take a Hanoi break if the time has come."
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
14 (and (not (input-pending-p))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
15 (prog1 hanoi-break-p
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
16 (setq hanoi-break-p nil))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
17 (hanoi-break)))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
18
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
19 ;;;###autoload
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
20 (defun hanoi-break ()
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
21 "Take a Hanoi break, son."
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
22 (interactive)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
23 (save-window-excursion
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
24 (eval (condition-case error
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
25 (if (not (yes-or-no-p "Take a break now? "))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
26 '(hanoi-break-schedule 60) ; Bug him again in one minute.
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
27 ;; Eat the screen.
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
28 (if (eq (selected-window) (minibuffer-window))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
29 (other-window 1))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
30 (delete-other-windows)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
31 (scroll-right (window-width))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
32 ;; Send him on his way.
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
33 (message "Take a break, son.")
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
34 (if (get-buffer "*Hanoi*")
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
35 (kill-buffer "*Hanoi*"))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
36 (condition-case ()
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
37 (progn
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
38 (hanoi (/ (window-width) 8))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
39 ;; Wait for him to come back.
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
40 (read-char)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
41 (kill-buffer "*Hanoi*"))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
42 (quit nil))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
43 '(hanoi-break-schedule)) ; Schedule next break.
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
44 (quit '(hanoi-break-schedule 60)) ; Bug him again in one minute.
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
45 ;;(error t)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
46 ))))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
47
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
48 ;;;###autoload
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
49 (defun hanoi-break-schedule (&optional time)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
50 "Schedule a break for ARG seconds from now (default: hanoi-break-interval)."
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
51 (interactive (list (and current-prefix-arg
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
52 (prefix-numeric-value current-prefix-arg))))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
53 (or time (setq time hanoi-break-interval))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
54 (run-at-time time nil 'hanoi-break-soon))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
55
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
56 (defun hanoi-break-soon ()
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
57 "Take a Hanoi break very soon."
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
58 (setq hanoi-break-p t))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
59
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
60 (defun cancel-hanoi-break ()
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
61 "Cancel scheduled Hanoi breaks."
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
62 (interactive)
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
63 (cancel-function-timers 'hanoi-break-soon))
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
64
454dc146502d Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
65 (provide 'hanoi-break)