aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoah Friedman1994-07-21 13:00:35 +0000
committerNoah Friedman1994-07-21 13:00:35 +0000
commit3c137244308d35fc8f2c548572411c858810b882 (patch)
tree60b0ba646aa031e5ed81addab5aa4fc091fec61b
parentcc669dd81045a9fdc4aa566140f750918ec39600 (diff)
downloademacs-3c137244308d35fc8f2c548572411c858810b882.tar.gz
emacs-3c137244308d35fc8f2c548572411c858810b882.zip
type-break-schedule: Remove autoload cookie.
type-break-check: Optimized for speed.
-rw-r--r--lisp/type-break.el100
1 files changed, 44 insertions, 56 deletions
diff --git a/lisp/type-break.el b/lisp/type-break.el
index 341895415b0..196d6b7df53 100644
--- a/lisp/type-break.el
+++ b/lisp/type-break.el
@@ -278,7 +278,6 @@ as per the function `type-break-schedule'."
278 (type-break-schedule)) 278 (type-break-schedule))
279 279
280 280
281;;;###autoload
282(defun type-break-schedule (&optional time) 281(defun type-break-schedule (&optional time)
283 "Schedule a typing break for TIME seconds from now. 282 "Schedule a typing break for TIME seconds from now.
284If time is not specified, default to `type-break-interval'." 283If time is not specified, default to `type-break-interval'."
@@ -313,61 +312,50 @@ type-break-mode."
313This may be the case either because the scheduled time has come \(and the 312This may be the case either because the scheduled time has come \(and the
314minimum keystroke threshold has been reached\) or because the maximum 313minimum keystroke threshold has been reached\) or because the maximum
315keystroke threshold has been exceeded." 314keystroke threshold has been exceeded."
316 (cond 315 (and type-break-mode
317 (type-break-mode 316 (let* ((min-threshold (car type-break-keystroke-threshold))
318 (let* ((threshold-pair (and (consp type-break-keystroke-threshold) 317 (max-threshold (cdr type-break-keystroke-threshold)))
319 type-break-keystroke-threshold)) 318 (and type-break-good-rest-interval
320 (min-threshold (car threshold-pair)) 319 (progn
321 (max-threshold (cdr threshold-pair))) 320 (and (> (type-break-time-difference
322 321 type-break-time-last-command (current-time))
323 ;; Reset schedule and keystroke count if user has been idle longer 322 type-break-good-rest-interval)
324 ;; than a normal resting period. 323 (progn
325 (cond 324 (setq type-break-keystroke-count 0)
326 (type-break-good-rest-interval 325 (setq type-break-time-last-break (current-time))
327 (and (> (type-break-time-difference type-break-time-last-command 326 (type-break-schedule)))
328 (current-time)) 327 (setq type-break-time-last-command (current-time))))
329 type-break-good-rest-interval) 328
330 (progn 329 (and type-break-keystroke-threshold
331 (setq type-break-keystroke-count 0) 330 (setq type-break-keystroke-count
332 (setq type-break-time-last-break (current-time)) 331 (+ type-break-keystroke-count (length (this-command-keys)))))
333 (type-break-schedule))) 332
334 (setq type-break-time-last-command (current-time)))) 333 ;; This has been optimized for speed; calls to input-pending-p and
335 334 ;; checking for the minibuffer window are only done if it would
336 (and threshold-pair 335 ;; matter for the sake of querying user.
337 (setq type-break-keystroke-count 336 (cond
338 (+ type-break-keystroke-count (length (this-command-keys))))) 337 (type-break-alarm-p
339 338 (cond
340 (cond 339 ((input-pending-p))
341 ((input-pending-p)) 340 ((eq (selected-window) (minibuffer-window)))
342 ((eq (selected-window) (minibuffer-window))) 341 ((and min-threshold
343 (type-break-alarm-p 342 (< type-break-keystroke-count min-threshold))
344 (cond 343 (type-break-schedule))
345 ((and min-threshold 344 (t
346 (< type-break-keystroke-count min-threshold)) 345 ;; If keystroke count is within min-threshold of
347 (type-break-schedule)) 346 ;; max-threshold, lower it to reduce the liklihood of an
348 (t 347 ;; immediate subsequent query.
349 ;; If the keystroke count is within min-threshold characters of 348 (and max-threshold
350 ;; the maximum threshold, set the count to min-threshold. That 349 min-threshold
351 ;; way, if the count was really close the threshold and the user 350 (< (- max-threshold type-break-keystroke-count) min-threshold)
352 ;; doesn't choose to take a break now, s/he won't be pestered 351 (setq type-break-keystroke-count min-threshold))
353 ;; almost immediately after saying "no"; that's what the query 352 (type-break-query))))
354 ;; interval delay is for. 353 ((and max-threshold
355 ;; On the other hand, don't set it too small (make it at least 354 (> type-break-keystroke-count max-threshold)
356 ;; min-threshold); that way we can be sure the user will be asked 355 (not (input-pending-p))
357 ;; again to take a break after the query interval has elapsed. 356 (not (eq (selected-window) (minibuffer-window))))
358 ;; If the user chooses to take a break now, the break function 357 (setq type-break-keystroke-count (or min-threshold 0))
359 ;; will reset the keystroke count anyway. 358 (type-break-query))))))
360 (and max-threshold
361 min-threshold
362 (< (- max-threshold type-break-keystroke-count) min-threshold)
363 (setq type-break-keystroke-count min-threshold))
364 (type-break-query))))
365 ((and max-threshold
366 (> type-break-keystroke-count max-threshold))
367 ;; Set it to the min threshold if possible, to be sure the user
368 ;; will be pestered again in at least a minute.
369 (setq type-break-keystroke-count (or min-threshold 0))
370 (type-break-query)))))))
371 359
372(defun type-break-query () 360(defun type-break-query ()
373 (condition-case () 361 (condition-case ()