diff options
| author | Noah Friedman | 2000-07-24 00:50:10 +0000 |
|---|---|---|
| committer | Noah Friedman | 2000-07-24 00:50:10 +0000 |
| commit | ad9534859721d7d8381d2c0fb73533d3cf7e60cd (patch) | |
| tree | 0b1564c43ad203439d9c9bacb8fb65fb82a69134 | |
| parent | 03a9c6d06a177fd9026779bcb952f906a7743690 (diff) | |
| download | emacs-ad9534859721d7d8381d2c0fb73533d3cf7e60cd.tar.gz emacs-ad9534859721d7d8381d2c0fb73533d3cf7e60cd.zip | |
(type-break): perform autosave.
Suggested by Stephen Gildea <gildea@intouchsys.com>.
(type-break-do-query): Cancel query schedule while performing
actual query, to avoid possibility of a second query being made
while first one is already in progress.
(type-break-time-stamp-format): New variable.
(type-break-time-stamp): New function.
(type-break-time-warning): Use it.
(type-break-keystroke-warning): Use it.
(type-break-noninteractive-query): Use it.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/type-break.el | 60 |
2 files changed, 55 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4482dabb70e..49fac791005 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,16 @@ | |||
| 1 | 2000-07-23 Noah Friedman <friedman@splode.com> | 1 | 2000-07-23 Noah Friedman <friedman@splode.com> |
| 2 | 2 | ||
| 3 | * type-break.el (type-break): perform autosave. | ||
| 4 | Suggested by Stephen Gildea <gildea@intouchsys.com>. | ||
| 5 | (type-break-do-query): Cancel query schedule while performing | ||
| 6 | actual query, to avoid possibility of a second query being made | ||
| 7 | while first one is already in progress. | ||
| 8 | (type-break-time-stamp-format): New variable. | ||
| 9 | (type-break-time-stamp): New function. | ||
| 10 | (type-break-time-warning): Use it. | ||
| 11 | (type-break-keystroke-warning): Use it. | ||
| 12 | (type-break-noninteractive-query): Use it. | ||
| 13 | |||
| 3 | * emacs-lisp/eldoc.el (eldoc-minor-mode-string): Add autoload | 14 | * emacs-lisp/eldoc.el (eldoc-minor-mode-string): Add autoload |
| 4 | cookie. | 15 | cookie. |
| 5 | Use add-minor-mode to set minor-mode-alist, if available. | 16 | Use add-minor-mode to set minor-mode-alist, if available. |
diff --git a/lisp/type-break.el b/lisp/type-break.el index cc52cfbb99b..407fd1bfeb0 100644 --- a/lisp/type-break.el +++ b/lisp/type-break.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; type-break.el --- encourage rests from typing at appropriate intervals | 1 | ;;; type-break.el --- encourage rests from typing at appropriate intervals |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1994, 95, 97, 2000 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Noah Friedman | 5 | ;; Author: Noah Friedman |
| 6 | ;; Maintainer: Noah Friedman <friedman@splode.com> | 6 | ;; Maintainer: Noah Friedman <friedman@splode.com> |
| @@ -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: type-break.el,v 1.22 1999/04/27 19:00:42 fx Exp kwzh $ | 11 | ;; $Id: type-break.el,v 1.23 2000/03/13 11:16:00 friedman Exp $ |
| 12 | 12 | ||
| 13 | ;; This file is part of GNU Emacs. | 13 | ;; This file is part of GNU Emacs. |
| 14 | 14 | ||
| @@ -61,7 +61,7 @@ | |||
| 61 | ;; This package was inspired by Roland McGrath's hanoi-break.el. | 61 | ;; This package was inspired by Roland McGrath's hanoi-break.el. |
| 62 | ;; Several people contributed feedback and ideas, including | 62 | ;; Several people contributed feedback and ideas, including |
| 63 | ;; Roland McGrath <roland@gnu.org> | 63 | ;; Roland McGrath <roland@gnu.org> |
| 64 | ;; Kleanthes Koniaris <kgk@martigny.ai.mit.edu> | 64 | ;; Kleanthes Koniaris <kgk@koniaris.com> |
| 65 | ;; Mark Ashton <mpashton@gnu.org> | 65 | ;; Mark Ashton <mpashton@gnu.org> |
| 66 | ;; Matt Wilding <wilding@cli.com> | 66 | ;; Matt Wilding <wilding@cli.com> |
| 67 | ;; Robert S. Boyer <boyer@cs.utexas.edu> | 67 | ;; Robert S. Boyer <boyer@cs.utexas.edu> |
| @@ -72,6 +72,7 @@ | |||
| 72 | (defgroup type-break nil | 72 | (defgroup type-break nil |
| 73 | "Encourage the user to take a rest from typing at suitable intervals." | 73 | "Encourage the user to take a rest from typing at suitable intervals." |
| 74 | :prefix "type-break" | 74 | :prefix "type-break" |
| 75 | :group 'type-break | ||
| 75 | :group 'keyboard) | 76 | :group 'keyboard) |
| 76 | 77 | ||
| 77 | ;;;###autoload | 78 | ;;;###autoload |
| @@ -151,12 +152,16 @@ If so, call the function specified in the value of the variable | |||
| 151 | :type 'boolean | 152 | :type 'boolean |
| 152 | :group 'type-break) | 153 | :group 'type-break) |
| 153 | 154 | ||
| 154 | (defvar type-break-query-function 'yes-or-no-p | 155 | (defcustom type-break-query-function 'yes-or-no-p |
| 155 | "Function to use for making query for a typing break. | 156 | "*Function to use for making query for a typing break. |
| 156 | It should take a string as an argument, the prompt. | 157 | It should take a string as an argument, the prompt. |
| 157 | Usually this should be set to `yes-or-no-p' or `y-or-n-p'. | 158 | Usually this should be set to `yes-or-no-p' or `y-or-n-p'. |
| 158 | 159 | ||
| 159 | To avoid being queried at all, set `type-break-query-mode' to `nil'.") | 160 | To avoid being queried at all, set `type-break-query-mode' to `nil'." |
| 161 | :type '(radio function | ||
| 162 | (function-item yes-or-no-p) | ||
| 163 | (function-item y-or-n-p)) | ||
| 164 | :group 'type-break) | ||
| 160 | 165 | ||
| 161 | (defcustom type-break-query-interval 60 | 166 | (defcustom type-break-query-interval 60 |
| 162 | "*Number of seconds between queries to take a break, if put off. | 167 | "*Number of seconds between queries to take a break, if put off. |
| @@ -181,7 +186,6 @@ will occur." | |||
| 181 | :type '(repeat integer) | 186 | :type '(repeat integer) |
| 182 | :group 'type-break) | 187 | :group 'type-break) |
| 183 | 188 | ||
| 184 | |||
| 185 | (defcustom type-break-warning-repeat 40 | 189 | (defcustom type-break-warning-repeat 40 |
| 186 | "*Number of keystrokes for which warnings should be repeated. | 190 | "*Number of keystrokes for which warnings should be repeated. |
| 187 | That is, for each of this many keystrokes the warning is redisplayed | 191 | That is, for each of this many keystrokes the warning is redisplayed |
| @@ -189,6 +193,12 @@ in the echo area to make sure it's really seen." | |||
| 189 | :type 'integer | 193 | :type 'integer |
| 190 | :group 'type-break) | 194 | :group 'type-break) |
| 191 | 195 | ||
| 196 | (defcustom type-break-time-stamp-format "[%H:%M] " | ||
| 197 | "*Timestamp format used to prefix messages. | ||
| 198 | Format specifiers are as used by `format-time-string'." | ||
| 199 | :type 'string | ||
| 200 | :group 'type-break) | ||
| 201 | |||
| 192 | (defcustom type-break-demo-functions | 202 | (defcustom type-break-demo-functions |
| 193 | '(type-break-demo-boring type-break-demo-life type-break-demo-hanoi) | 203 | '(type-break-demo-boring type-break-demo-life type-break-demo-hanoi) |
| 194 | "*List of functions to consider running as demos during typing breaks. | 204 | "*List of functions to consider running as demos during typing breaks. |
| @@ -232,13 +242,14 @@ See also `type-break-mode-line-format' and its members." | |||
| 232 | type-break-mode-line-break-string)) | 242 | type-break-mode-line-break-string)) |
| 233 | 243 | ||
| 234 | (defvar type-break-mode-line-break-message-p nil) | 244 | (defvar type-break-mode-line-break-message-p nil) |
| 235 | (defvar type-break-mode-line-break-string " *** TAKE A TYPING BREAK ***") | 245 | (defvar type-break-mode-line-break-string " *** TAKE A TYPING BREAK NOW ***") |
| 236 | 246 | ||
| 237 | (defvar type-break-mode-line-warning | 247 | (defvar type-break-mode-line-warning |
| 238 | '(type-break-mode-line-break-message-p | 248 | '(type-break-mode-line-break-message-p |
| 239 | ("") | 249 | ("") |
| 240 | (type-break-warning-countdown-string | 250 | (type-break-warning-countdown-string |
| 241 | (" ***Break in " | 251 | (" *** " |
| 252 | "Break in " | ||
| 242 | type-break-warning-countdown-string | 253 | type-break-warning-countdown-string |
| 243 | " " | 254 | " " |
| 244 | type-break-warning-countdown-string-type | 255 | type-break-warning-countdown-string-type |
| @@ -448,6 +459,7 @@ During the break, a demo selected from the functions listed in | |||
| 448 | After the typing break is finished, the next break is scheduled | 459 | After the typing break is finished, the next break is scheduled |
| 449 | as per the function `type-break-schedule'." | 460 | as per the function `type-break-schedule'." |
| 450 | (interactive) | 461 | (interactive) |
| 462 | (do-auto-save) | ||
| 451 | (type-break-cancel-schedule) | 463 | (type-break-cancel-schedule) |
| 452 | (let ((continue t) | 464 | (let ((continue t) |
| 453 | (start-time (current-time))) | 465 | (start-time (current-time))) |
| @@ -483,7 +495,8 @@ as per the function `type-break-schedule'." | |||
| 483 | ; (setq continue nil)) | 495 | ; (setq continue nil)) |
| 484 | ((funcall | 496 | ((funcall |
| 485 | type-break-query-function | 497 | type-break-query-function |
| 486 | (format "You really ought to rest %s more. Continue break? " | 498 | (format "%sYou really ought to rest %s more. Continue break? " |
| 499 | (type-break-time-stamp) | ||
| 487 | (type-break-format-time (- type-break-good-rest-interval | 500 | (type-break-format-time (- type-break-good-rest-interval |
| 488 | break-secs))))) | 501 | break-secs))))) |
| 489 | (t | 502 | (t |
| @@ -594,8 +607,6 @@ keystroke threshold has been exceeded." | |||
| 594 | (setq type-break-time-last-command (current-time)))) | 607 | (setq type-break-time-last-command (current-time)))) |
| 595 | 608 | ||
| 596 | (and type-break-keystroke-threshold | 609 | (and type-break-keystroke-threshold |
| 597 | ;; next line is test for 20.2 that can be deleted | ||
| 598 | ;;(setq type-break-keystroke-count (1+ type-break-keystroke-count)) | ||
| 599 | (let ((keys (this-command-keys))) | 610 | (let ((keys (this-command-keys))) |
| 600 | (cond | 611 | (cond |
| 601 | ;; Ignore mouse motion | 612 | ;; Ignore mouse motion |
| @@ -678,8 +689,14 @@ keystroke threshold has been exceeded." | |||
| 678 | ;; which hoses undo or yank-pop (if you happened to be | 689 | ;; which hoses undo or yank-pop (if you happened to be |
| 679 | ;; yanking just when the query occurred). | 690 | ;; yanking just when the query occurred). |
| 680 | (this-command this-command)) | 691 | (this-command this-command)) |
| 692 | ;; Cancel schedule to prevent possibility of a second query | ||
| 693 | ;; from taking place before this one has even returned. | ||
| 694 | ;; The condition-case wrapper will reschedule on quit. | ||
| 695 | (type-break-cancel-schedule) | ||
| 681 | (funcall type-break-query-function | 696 | (funcall type-break-query-function |
| 682 | "Take a break from typing now? ")) | 697 | (format "%s%s" |
| 698 | (type-break-time-stamp) | ||
| 699 | "Take a break from typing now? "))) | ||
| 683 | (type-break)) | 700 | (type-break)) |
| 684 | (t | 701 | (t |
| 685 | (type-break-schedule type-break-query-interval))) | 702 | (type-break-schedule type-break-query-interval))) |
| @@ -695,7 +712,8 @@ this or ask the user to start one right now." | |||
| 695 | (type-break-mode-line-message-mode) | 712 | (type-break-mode-line-message-mode) |
| 696 | (t | 713 | (t |
| 697 | (beep t) | 714 | (beep t) |
| 698 | (message "You should take a typing break now. Do `M-x type-break'.") | 715 | (message "%sYou should take a typing break now. Do `M-x type-break'." |
| 716 | (type-break-time-stamp)) | ||
| 699 | (sit-for 1) | 717 | (sit-for 1) |
| 700 | (beep t) | 718 | (beep t) |
| 701 | ;; return nil so query caller knows to reset reminder, as if user | 719 | ;; return nil so query caller knows to reset reminder, as if user |
| @@ -720,7 +738,8 @@ this or ask the user to start one right now." | |||
| 720 | ((not type-break-mode-line-message-mode) | 738 | ((not type-break-mode-line-message-mode) |
| 721 | ;; Pause for a moment so any previous message can be seen. | 739 | ;; Pause for a moment so any previous message can be seen. |
| 722 | (sit-for 2) | 740 | (sit-for 2) |
| 723 | (message "Warning: typing break due in %s." | 741 | (message "%sWarning: typing break due in %s." |
| 742 | (type-break-time-stamp) | ||
| 724 | (type-break-format-time timeleft)) | 743 | (type-break-format-time timeleft)) |
| 725 | (setq type-break-time-warning-count | 744 | (setq type-break-time-warning-count |
| 726 | (1- type-break-time-warning-count)))))) | 745 | (1- type-break-time-warning-count)))))) |
| @@ -743,7 +762,8 @@ this or ask the user to start one right now." | |||
| 743 | ((memq this-command '(digit-argument universal-argument))) | 762 | ((memq this-command '(digit-argument universal-argument))) |
| 744 | ((not type-break-mode-line-message-mode) | 763 | ((not type-break-mode-line-message-mode) |
| 745 | (sit-for 2) | 764 | (sit-for 2) |
| 746 | (message "Warning: typing break due in %s keystrokes." | 765 | (message "%sWarning: typing break due in %s keystrokes." |
| 766 | (type-break-time-stamp) | ||
| 747 | (- (cdr type-break-keystroke-threshold) | 767 | (- (cdr type-break-keystroke-threshold) |
| 748 | type-break-keystroke-count)) | 768 | type-break-keystroke-count)) |
| 749 | (setq type-break-keystroke-warning-count | 769 | (setq type-break-keystroke-warning-count |
| @@ -891,6 +911,13 @@ FRAC should be the inverse of the fractional value; for example, a value of | |||
| 891 | 911 | ||
| 892 | (list high low micro))) | 912 | (list high low micro))) |
| 893 | 913 | ||
| 914 | (defun type-break-time-stamp (&optional when) | ||
| 915 | (if (fboundp 'format-time-string) | ||
| 916 | (format-time-string type-break-time-stamp-format when) | ||
| 917 | ;; Emacs 19.28 and prior do not have format-time-string. | ||
| 918 | ;; In that case, result is not customizable. Upgrade today! | ||
| 919 | (format "[%s] " (substring (current-time-string when) 11 16)))) | ||
| 920 | |||
| 894 | (defun type-break-format-time (secs) | 921 | (defun type-break-format-time (secs) |
| 895 | (let ((mins (/ secs 60))) | 922 | (let ((mins (/ secs 60))) |
| 896 | (cond | 923 | (cond |
| @@ -1062,4 +1089,5 @@ With optional non-nil ALL, force redisplay of all mode-lines." | |||
| 1062 | 1089 | ||
| 1063 | (if type-break-mode | 1090 | (if type-break-mode |
| 1064 | (type-break-mode 1)) | 1091 | (type-break-mode 1)) |
| 1092 | |||
| 1065 | ;;; type-break.el ends here | 1093 | ;;; type-break.el ends here |