diff options
| -rw-r--r-- | lisp/type-break.el | 86 |
1 files changed, 62 insertions, 24 deletions
diff --git a/lisp/type-break.el b/lisp/type-break.el index 1ff6e949ddb..a367b0539a8 100644 --- a/lisp/type-break.el +++ b/lisp/type-break.el | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | ;; Status: Works in GNU Emacs 19.25 or later, some versions of XEmacs | 8 | ;; Status: Works in GNU Emacs 19.25 or later, some versions of XEmacs |
| 9 | ;; Created: 1994-07-13 | 9 | ;; Created: 1994-07-13 |
| 10 | 10 | ||
| 11 | ;; $Id$ | 11 | ;; $Id: type-break.el,v 1.12 1997/06/23 05:28:51 friedman Exp stephen $ |
| 12 | 12 | ||
| 13 | ;; This file is part of GNU Emacs. | 13 | ;; This file is part of GNU Emacs. |
| 14 | 14 | ||
| @@ -69,17 +69,31 @@ | |||
| 69 | ;;; Code: | 69 | ;;; Code: |
| 70 | 70 | ||
| 71 | 71 | ||
| 72 | (defgroup type-break nil | ||
| 73 | "Encourage the user to take a rest from typing at suitable intervals." | ||
| 74 | :prefix "type-break" | ||
| 75 | :group 'keyboard) | ||
| 76 | |||
| 72 | ;;;###autoload | 77 | ;;;###autoload |
| 73 | (defvar type-break-mode nil | 78 | (defcustom type-break-mode nil |
| 74 | "*Non-`nil' means typing break mode is enabled. | 79 | "*Non-`nil' means typing break mode is enabled. |
| 75 | See the docstring for the `type-break-mode' command for more information.") | 80 | See the docstring for the `type-break-mode' command for more information. |
| 81 | You must modify via \\[customize] for this variable to have an effect." | ||
| 82 | :set (lambda (symbol value) | ||
| 83 | (type-break-mode (if value 1 -1))) | ||
| 84 | :initialize 'custom-initialize-default | ||
| 85 | :type 'boolean | ||
| 86 | :group 'type-break | ||
| 87 | :require 'type-break) | ||
| 76 | 88 | ||
| 77 | ;;;###autoload | 89 | ;;;###autoload |
| 78 | (defvar type-break-interval (* 60 60) | 90 | (defcustom type-break-interval (* 60 60) |
| 79 | "*Number of seconds between scheduled typing breaks.") | 91 | "*Number of seconds between scheduled typing breaks." |
| 92 | :type 'integer | ||
| 93 | :group 'type-break) | ||
| 80 | 94 | ||
| 81 | ;;;###autoload | 95 | ;;;###autoload |
| 82 | (defvar type-break-good-rest-interval (/ type-break-interval 6) | 96 | (defcustom type-break-good-rest-interval (/ type-break-interval 6) |
| 83 | "*Number of seconds of idle time considered to be an adequate typing rest. | 97 | "*Number of seconds of idle time considered to be an adequate typing rest. |
| 84 | 98 | ||
| 85 | When this variable is non-`nil', emacs checks the idle time between | 99 | When this variable is non-`nil', emacs checks the idle time between |
| @@ -87,10 +101,12 @@ keystrokes. If this idle time is long enough to be considered a \"good\" | |||
| 87 | rest from typing, then the next typing break is simply rescheduled for later. | 101 | rest from typing, then the next typing break is simply rescheduled for later. |
| 88 | 102 | ||
| 89 | If a break is interrupted before this much time elapses, the user will be | 103 | If a break is interrupted before this much time elapses, the user will be |
| 90 | asked whether or not really to interrupt the break.") | 104 | asked whether or not really to interrupt the break." |
| 105 | :type 'integer | ||
| 106 | :group 'type-break) | ||
| 91 | 107 | ||
| 92 | ;;;###autoload | 108 | ;;;###autoload |
| 93 | (defvar type-break-keystroke-threshold | 109 | (defcustom type-break-keystroke-threshold |
| 94 | ;; Assuming typing speed is 35wpm (on the average, do you really | 110 | ;; Assuming typing speed is 35wpm (on the average, do you really |
| 95 | ;; type more than that in a minute? I spend a lot of time reading mail | 111 | ;; type more than that in a minute? I spend a lot of time reading mail |
| 96 | ;; and simply studying code in buffers) and average word length is | 112 | ;; and simply studying code in buffers) and average word length is |
| @@ -105,7 +121,7 @@ asked whether or not really to interrupt the break.") | |||
| 105 | (lower (/ upper 5))) | 121 | (lower (/ upper 5))) |
| 106 | (cons lower upper)) | 122 | (cons lower upper)) |
| 107 | "*Upper and lower bound on number of keystrokes for considering typing break. | 123 | "*Upper and lower bound on number of keystrokes for considering typing break. |
| 108 | This structure is a pair of numbers. | 124 | This structure is a pair of numbers (MIN . MAX). |
| 109 | 125 | ||
| 110 | The first number is the minimum number of keystrokes that must have been | 126 | The first number is the minimum number of keystrokes that must have been |
| 111 | entered since the last typing break before considering another one, even if | 127 | entered since the last typing break before considering another one, even if |
| @@ -123,12 +139,16 @@ Keys with bucky bits (shift, control, meta, etc) are counted as only one | |||
| 123 | keystroke even though they really require multiple keys to generate them. | 139 | keystroke even though they really require multiple keys to generate them. |
| 124 | 140 | ||
| 125 | The command `type-break-guesstimate-keystroke-threshold' can be used to | 141 | The command `type-break-guesstimate-keystroke-threshold' can be used to |
| 126 | guess a reasonably good pair of values for this variable.") | 142 | guess a reasonably good pair of values for this variable." |
| 143 | :type 'sexp | ||
| 144 | :group 'type-break) | ||
| 127 | 145 | ||
| 128 | (defvar type-break-query-mode t | 146 | (defcustom type-break-query-mode t |
| 129 | "*Non-`nil' means ask whether or not to prompt user for breaks. | 147 | "*Non-`nil' means ask whether or not to prompt user for breaks. |
| 130 | If so, call the function specified in the value of the variable | 148 | If so, call the function specified in the value of the variable |
| 131 | `type-break-query-function' to do the asking.") | 149 | `type-break-query-function' to do the asking." |
| 150 | :type 'boolean | ||
| 151 | :group 'type-break) | ||
| 132 | 152 | ||
| 133 | (defvar type-break-query-function 'yes-or-no-p | 153 | (defvar type-break-query-function 'yes-or-no-p |
| 134 | "Function to use for making query for a typing break. | 154 | "Function to use for making query for a typing break. |
| @@ -137,36 +157,47 @@ Usually this should be set to `yes-or-no-p' or `y-or-n-p'. | |||
| 137 | 157 | ||
| 138 | To avoid being queried at all, set `type-break-query-mode' to `nil'.") | 158 | To avoid being queried at all, set `type-break-query-mode' to `nil'.") |
| 139 | 159 | ||
| 140 | (defvar type-break-query-interval 60 | 160 | (defcustom type-break-query-interval 60 |
| 141 | "*Number of seconds between queries to take a break, if put off. | 161 | "*Number of seconds between queries to take a break, if put off. |
| 142 | The user will continue to be prompted at this interval until he or she | 162 | The user will continue to be prompted at this interval until he or she |
| 143 | finally submits to taking a typing break.") | 163 | finally submits to taking a typing break." |
| 164 | :type 'integer | ||
| 165 | :group 'type-break) | ||
| 144 | 166 | ||
| 145 | (defvar type-break-time-warning-intervals '(300 120 60 30) | 167 | (defcustom type-break-time-warning-intervals '(300 120 60 30) |
| 146 | "*List of time intervals for warnings about upcoming typing break. | 168 | "*List of time intervals for warnings about upcoming typing break. |
| 147 | At each of the intervals (specified in seconds) away from a scheduled | 169 | At each of the intervals (specified in seconds) away from a scheduled |
| 148 | typing break, print a warning in the echo area.") | 170 | typing break, print a warning in the echo area." |
| 171 | :type '(repeat integer) | ||
| 172 | :group 'type-break) | ||
| 149 | 173 | ||
| 150 | (defvar type-break-keystroke-warning-intervals '(300 200 100 50) | 174 | (defcustom type-break-keystroke-warning-intervals '(300 200 100 50) |
| 151 | "*List of keystroke measurements for warnings about upcoming typing break. | 175 | "*List of keystroke measurements for warnings about upcoming typing break. |
| 152 | At each of the intervals (specified in keystrokes) away from the upper | 176 | At each of the intervals (specified in keystrokes) away from the upper |
| 153 | keystroke threshold, print a warning in the echo area. | 177 | keystroke threshold, print a warning in the echo area. |
| 154 | If either this variable or the upper threshold is set, then no warnings | 178 | If either this variable or the upper threshold is set, then no warnings |
| 155 | Will occur.") | 179 | will occur." |
| 180 | :type '(repeat integer) | ||
| 181 | :group 'type-break) | ||
| 182 | |||
| 156 | 183 | ||
| 157 | (defvar type-break-warning-repeat 40 | 184 | (defcustom type-break-warning-repeat 40 |
| 158 | "*Number of keystrokes for which warnings should be repeated. | 185 | "*Number of keystrokes for which warnings should be repeated. |
| 159 | That is, for each of this many keystrokes the warning is redisplayed | 186 | That is, for each of this many keystrokes the warning is redisplayed |
| 160 | in the echo area to make sure it's really seen.") | 187 | in the echo area to make sure it's really seen." |
| 188 | :type 'integer | ||
| 189 | :group 'type-break) | ||
| 161 | 190 | ||
| 162 | (defvar type-break-demo-functions | 191 | (defcustom type-break-demo-functions |
| 163 | '(type-break-demo-boring type-break-demo-life type-break-demo-hanoi) | 192 | '(type-break-demo-boring type-break-demo-life type-break-demo-hanoi) |
| 164 | "*List of functions to consider running as demos during typing breaks. | 193 | "*List of functions to consider running as demos during typing breaks. |
| 165 | When a typing break begins, one of these functions is selected randomly | 194 | When a typing break begins, one of these functions is selected randomly |
| 166 | to have emacs do something interesting. | 195 | to have emacs do something interesting. |
| 167 | 196 | ||
| 168 | Any function in this list should start a demo which ceases as soon as a | 197 | Any function in this list should start a demo which ceases as soon as a |
| 169 | key is pressed.") | 198 | key is pressed." |
| 199 | :type '(repeat function) | ||
| 200 | :group 'type-break) | ||
| 170 | 201 | ||
| 171 | (defvar type-break-post-command-hook '(type-break-check) | 202 | (defvar type-break-post-command-hook '(type-break-check) |
| 172 | "Hook run indirectly by post-command-hook for typing break functions. | 203 | "Hook run indirectly by post-command-hook for typing break functions. |
| @@ -180,11 +211,13 @@ remove themselves after running.") | |||
| 180 | 211 | ||
| 181 | ;; Mode line frobs | 212 | ;; Mode line frobs |
| 182 | 213 | ||
| 183 | (defvar type-break-mode-line-message-mode nil | 214 | (defcustom type-break-mode-line-message-mode nil |
| 184 | "*Non-`nil' means put type-break related messages in the mode line. | 215 | "*Non-`nil' means put type-break related messages in the mode line. |
| 185 | Otherwise, messages typically go in the echo area. | 216 | Otherwise, messages typically go in the echo area. |
| 186 | 217 | ||
| 187 | See also `type-break-mode-line-format' and its members.") | 218 | See also `type-break-mode-line-format' and its members." |
| 219 | :type 'boolean | ||
| 220 | :group 'type-break) | ||
| 188 | 221 | ||
| 189 | (defvar type-break-mode-line-format | 222 | (defvar type-break-mode-line-format |
| 190 | '(type-break-mode-line-message-mode | 223 | '(type-break-mode-line-message-mode |
| @@ -247,6 +280,7 @@ It will be either \"seconds\" or \"keystrokes\".") | |||
| 247 | ("\\bLucid\\b" . lucid) | 280 | ("\\bLucid\\b" . lucid) |
| 248 | ("^Nemacs\\b" . nemacs) | 281 | ("^Nemacs\\b" . nemacs) |
| 249 | ("^GNU Emacs 19" . standard19) | 282 | ("^GNU Emacs 19" . standard19) |
| 283 | ("^GNU Emacs 20" . standard19) | ||
| 250 | ("^GNU Emacs 18" . emacs18))) | 284 | ("^GNU Emacs 18" . emacs18))) |
| 251 | result) | 285 | result) |
| 252 | (while alist | 286 | (while alist |
| @@ -559,6 +593,8 @@ keystroke threshold has been exceeded." | |||
| 559 | (setq type-break-time-last-command (current-time)))) | 593 | (setq type-break-time-last-command (current-time)))) |
| 560 | 594 | ||
| 561 | (and type-break-keystroke-threshold | 595 | (and type-break-keystroke-threshold |
| 596 | ;; next line is test for 20.2 that can be deleted | ||
| 597 | ;;(setq type-break-keystroke-count (1+ type-break-keystroke-count)) | ||
| 562 | (let ((keys (this-command-keys))) | 598 | (let ((keys (this-command-keys))) |
| 563 | (cond | 599 | (cond |
| 564 | ;; Ignore mouse motion | 600 | ;; Ignore mouse motion |
| @@ -1023,4 +1059,6 @@ With optional non-nil ALL, force redisplay of all mode-lines." | |||
| 1023 | 1059 | ||
| 1024 | (provide 'type-break) | 1060 | (provide 'type-break) |
| 1025 | 1061 | ||
| 1062 | (if type-break-mode | ||
| 1063 | (type-break-mode 1)) | ||
| 1026 | ;;; type-break.el ends here | 1064 | ;;; type-break.el ends here |