diff options
| author | Richard M. Stallman | 1996-08-29 01:37:38 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-08-29 01:37:38 +0000 |
| commit | 7fd5b62d23d331307a167c8b75b3a2b7ffa82fe0 (patch) | |
| tree | 580e58139d679f34d595d467d66f1fa88e254e8a | |
| parent | 73ba610ac45d310291da6d96894d565a24196322 (diff) | |
| download | emacs-7fd5b62d23d331307a167c8b75b3a2b7ffa82fe0.tar.gz emacs-7fd5b62d23d331307a167c8b75b3a2b7ffa82fe0.zip | |
(display-time): Call display-time-mode.
(display-time-mode): Take arg or toggle, as a minor mode.
| -rw-r--r-- | lisp/time.el | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/lisp/time.el b/lisp/time.el index 59dc075cfd8..df819d25677 100644 --- a/lisp/time.el +++ b/lisp/time.el | |||
| @@ -57,27 +57,49 @@ If that file system seems to be up, the value is nil.") | |||
| 57 | 57 | ||
| 58 | ;;;###autoload | 58 | ;;;###autoload |
| 59 | (defun display-time () | 59 | (defun display-time () |
| 60 | "Display current time, load level, and mail flag in mode line of each buffer. | 60 | "Enable display of time, load level, and mail flag in mode lines. |
| 61 | Updates automatically every minute. | 61 | This display updates automatically every minute. |
| 62 | If `display-time-day-and-date' is non-nil, the current day and date | 62 | If `display-time-day-and-date' is non-nil, the current day and date |
| 63 | are displayed as well. | 63 | are displayed as well. |
| 64 | After each update, `display-time-hook' is run with `run-hooks'." | 64 | This runs the normal hook `display-time-hook' after each update." |
| 65 | (interactive) | 65 | (interactive) |
| 66 | (setq display-time-string "") | 66 | (display-time-mode 1)) |
| 67 | (or global-mode-string (setq global-mode-string '(""))) | 67 | |
| 68 | (or (memq 'display-time-string global-mode-string) | 68 | ;;;###autoload |
| 69 | (setq global-mode-string | 69 | (defun display-time-mode (arg) |
| 70 | (append global-mode-string '(display-time-string)))) | 70 | "Toggle display of time, load level, and mail flag in mode lines. |
| 71 | ;; Setup the time timer. | 71 | With a numeric arg, enable this display if arg is positive. |
| 72 | (and display-time-timer (cancel-timer display-time-timer)) | 72 | |
| 73 | (setq display-time-timer | 73 | When this display is enabled, it updates automatically every minute. |
| 74 | ;; Start timer at the beginning of the next minute. | 74 | If `display-time-day-and-date' is non-nil, the current day and date |
| 75 | (run-at-time (apply 'encode-time 60 (cdr (decode-time))) | 75 | are displayed as well. |
| 76 | display-time-interval 'display-time-event-handler)) | 76 | This runs the normal hook `display-time-hook' after each update." |
| 77 | ;; Make the time appear right away. | 77 | (interactive "P") |
| 78 | (display-time-update) | 78 | (let ((on (if (null arg) |
| 79 | ;; When you get new mail, clear "Mail" from the mode line. | 79 | (not display-time-timer) |
| 80 | (add-hook 'rmail-after-get-new-mail-hook 'display-time-event-handler)) | 80 | (> (prefix-numeric-value arg) 0)))) |
| 81 | (and display-time-timer (cancel-timer display-time-timer)) | ||
| 82 | (setq display-time-timer nil) | ||
| 83 | (setq display-time-string "") | ||
| 84 | (or global-mode-string (setq global-mode-string '(""))) | ||
| 85 | (if on | ||
| 86 | (progn | ||
| 87 | (or (memq 'display-time-string global-mode-string) | ||
| 88 | (setq global-mode-string | ||
| 89 | (append global-mode-string '(display-time-string)))) | ||
| 90 | ;; Set up the time timer. | ||
| 91 | (setq display-time-timer | ||
| 92 | ;; Start timer at the beginning of the next minute. | ||
| 93 | (run-at-time (apply 'encode-time 60 (cdr (decode-time))) | ||
| 94 | display-time-interval 'display-time-event-handler)) | ||
| 95 | ;; Make the time appear right away. | ||
| 96 | (display-time-update) | ||
| 97 | ;; When you get new mail, clear "Mail" from the mode line. | ||
| 98 | (add-hook 'rmail-after-get-new-mail-hook | ||
| 99 | 'display-time-event-handler)) | ||
| 100 | (remove-hook 'rmail-after-get-new-mail-hook | ||
| 101 | 'display-time-event-handler)))) | ||
| 102 | |||
| 81 | 103 | ||
| 82 | (defvar display-time-string-forms | 104 | (defvar display-time-string-forms |
| 83 | '((if display-time-day-and-date | 105 | '((if display-time-day-and-date |