aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoah Friedman1994-07-19 04:41:50 +0000
committerNoah Friedman1994-07-19 04:41:50 +0000
commitf486195cb1d38aeef29c4d63f0f2aa8cf6730cd5 (patch)
tree619bb5b182e60c73c7ed414e45cf092918f48d5e
parent6b62b567cbda4980bf5c80526a078d494338a086 (diff)
downloademacs-f486195cb1d38aeef29c4d63f0f2aa8cf6730cd5.tar.gz
emacs-f486195cb1d38aeef29c4d63f0f2aa8cf6730cd5.zip
type-break-keystroke-threshold: Change default wpm to 30 and lower
threshold to 1/5, rather than 1/4, of upper. type-break-guestimate-keystroke-threshold: Change threshold fraction here too. type-break-demo-life: Restart when all life perishes.
-rw-r--r--lisp/type-break.el46
1 files changed, 29 insertions, 17 deletions
diff --git a/lisp/type-break.el b/lisp/type-break.el
index 511d977b868..84e1dab026e 100644
--- a/lisp/type-break.el
+++ b/lisp/type-break.el
@@ -44,7 +44,11 @@
44 44
45;;; Setting type-break-good-rest-interval makes emacs cons like a maniac 45;;; Setting type-break-good-rest-interval makes emacs cons like a maniac
46;;; because of repeated calls to `current-time'. There's not really any 46;;; because of repeated calls to `current-time'. There's not really any
47;;; good way to avoid this without disabling the variable. 47;;; good way to avoid this without disabling the variable. In fact, this
48;;; package makes emacs somewhat cycle intensive because a small amount of
49;;; extra lisp code gets evaluated on every keystroke anyway. But what's
50;;; more important, a few computer cycles or reducing your risk of
51;;; repetitive strain injury?
48 52
49;;; This package was inspired by Roland McGrath's hanoi-break.el. 53;;; This package was inspired by Roland McGrath's hanoi-break.el.
50 54
@@ -83,16 +87,18 @@ finally submits to taking a typing break.")
83 87
84;;;###autoload 88;;;###autoload
85(defvar type-break-keystroke-threshold 89(defvar type-break-keystroke-threshold
86 ;; Assuming average typing speed is 45wpm and the average word length is 90 ;; Assuming typing speed is 30wpm (on the average, do you really
91 ;; type more than that in a minute? I spend a lot of time reading mail
92 ;; and simply studying code in buffers) and average word length is
87 ;; about 5 letters, default upper threshold to the average number of 93 ;; about 5 letters, default upper threshold to the average number of
88 ;; keystrokes one is likely to type in a break interval. That way if the 94 ;; keystrokes one is likely to type in a break interval. That way if the
89 ;; user goes through a furious burst of typing activity, cause a typing 95 ;; user goes through a furious burst of typing activity, cause a typing
90 ;; break to be required sooner than originally scheduled. 96 ;; break to be required sooner than originally scheduled.
91 ;; Conversely, the minimum threshold should be about a quarter of this. 97 ;; Conversely, the minimum threshold should be about a fifth of this.
92 (let* ((wpm 45) 98 (let* ((wpm 30)
93 (avg-word-length 5) 99 (avg-word-length 5)
94 (upper (* wpm avg-word-length (/ type-break-interval 60))) 100 (upper (* wpm avg-word-length (/ type-break-interval 60)))
95 (lower (/ upper 4))) 101 (lower (/ upper 5)))
96 (cons lower upper)) 102 (cons lower upper))
97 "*Upper and lower bound on number of keystrokes for considering typing break. 103 "*Upper and lower bound on number of keystrokes for considering typing break.
98This structure is a pair of numbers. 104This structure is a pair of numbers.
@@ -387,17 +393,23 @@ keystroke threshold has been exceeded."
387;; Also, clean up the *Life* buffer after we're done. 393;; Also, clean up the *Life* buffer after we're done.
388(defun type-break-demo-life () 394(defun type-break-demo-life ()
389 "Take a typing break and get a life." 395 "Take a typing break and get a life."
390 (and (get-buffer "*Life*") 396 (let ((continue t))
391 (kill-buffer "*Life*")) 397 (while continue
392 (condition-case () 398 (setq continue nil)
393 (progn 399 (and (get-buffer "*Life*")
394 (life 3) 400 (kill-buffer "*Life*"))
395 ;; Wait for user to come back. 401 (condition-case ()
396 (read-char) 402 (progn
397 (kill-buffer "*Life*")) 403 (life 3)
398 (quit 404 (kill-buffer "*Life*"))
399 (and (get-buffer "*Life*") 405 (life-extinct
400 (kill-buffer "*Life*"))))) 406 (message (get 'life-extinct 'error-message))
407 (sit-for 3)
408 ;; restart demo
409 (setq continue t))
410 (quit
411 (and (get-buffer "*Life*")
412 (kill-buffer "*Life*")))))))
401 413
402 414
403;;;###autoload 415;;;###autoload
@@ -448,7 +460,7 @@ FRAC should be the inverse of the fractional value; for example, a value of
4482 would mean to use one half, a value of 4 would mean to use one quarter, etc." 4602 would mean to use one half, a value of 4 would mean to use one quarter, etc."
449 (interactive "nHow many words per minute do you type? ") 461 (interactive "nHow many words per minute do you type? ")
450 (let* ((upper (* wpm (or wordlen 5) (/ type-break-interval 60))) 462 (let* ((upper (* wpm (or wordlen 5) (/ type-break-interval 60)))
451 (lower (/ upper (or frac 4)))) 463 (lower (/ upper (or frac 5))))
452 (or type-break-keystroke-threshold 464 (or type-break-keystroke-threshold
453 (setq type-break-keystroke-threshold (cons nil nil))) 465 (setq type-break-keystroke-threshold (cons nil nil)))
454 (setcar type-break-keystroke-threshold lower) 466 (setcar type-break-keystroke-threshold lower)