diff options
| author | Stefan Monnier | 2000-09-29 03:26:00 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-09-29 03:26:00 +0000 |
| commit | 57ce63c47017b2f81b576019f5a3fc7de58f84ff (patch) | |
| tree | 5cdf766c4c7936d10995e2383cbce34208d09c5c | |
| parent | 0b2cf11f544cf39b7e79ca9a049027557f6921a0 (diff) | |
| download | emacs-57ce63c47017b2f81b576019f5a3fc7de58f84ff.tar.gz emacs-57ce63c47017b2f81b576019f5a3fc7de58f84ff.zip | |
(display-time-mode): Use define-minor-mode.
| -rw-r--r-- | lisp/time.el | 81 |
1 files changed, 30 insertions, 51 deletions
diff --git a/lisp/time.el b/lisp/time.el index 756aa6ad8b9..1a5cb04986b 100644 --- a/lisp/time.el +++ b/lisp/time.el | |||
| @@ -34,20 +34,6 @@ | |||
| 34 | :group 'mail) | 34 | :group 'mail) |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | ;;;###autoload | ||
| 38 | (defcustom display-time-mode nil | ||
| 39 | "Toggle display of time, load level, and mail flag in mode lines. | ||
| 40 | Setting this variable directly does not take effect; | ||
| 41 | use either \\[customize] or the function `display-time-mode'." | ||
| 42 | :set (lambda (symbol value) | ||
| 43 | (display-time-mode (or value 0))) | ||
| 44 | :initialize 'custom-initialize-default | ||
| 45 | :type 'boolean | ||
| 46 | :group 'display-time | ||
| 47 | :require 'time | ||
| 48 | :version "20.3") | ||
| 49 | |||
| 50 | |||
| 51 | (defcustom display-time-mail-file nil | 37 | (defcustom display-time-mail-file nil |
| 52 | "*File name of mail inbox file, for indicating existence of new mail. | 38 | "*File name of mail inbox file, for indicating existence of new mail. |
| 53 | Non-nil and not a string means don't check for mail. nil means use | 39 | Non-nil and not a string means don't check for mail. nil means use |
| @@ -104,41 +90,6 @@ This runs the normal hook `display-time-hook' after each update." | |||
| 104 | (interactive) | 90 | (interactive) |
| 105 | (display-time-mode 1)) | 91 | (display-time-mode 1)) |
| 106 | 92 | ||
| 107 | ;;;###autoload | ||
| 108 | (defun display-time-mode (arg) | ||
| 109 | "Toggle display of time, load level, and mail flag in mode lines. | ||
| 110 | With a numeric arg, enable this display if arg is positive. | ||
| 111 | |||
| 112 | When this display is enabled, it updates automatically every minute. | ||
| 113 | If `display-time-day-and-date' is non-nil, the current day and date | ||
| 114 | are displayed as well. | ||
| 115 | This runs the normal hook `display-time-hook' after each update." | ||
| 116 | (interactive "P") | ||
| 117 | (let ((on (if (null arg) | ||
| 118 | (not display-time-timer) | ||
| 119 | (> (prefix-numeric-value arg) 0)))) | ||
| 120 | (setq display-time-mode on) | ||
| 121 | (and display-time-timer (cancel-timer display-time-timer)) | ||
| 122 | (setq display-time-timer nil) | ||
| 123 | (setq display-time-string "") | ||
| 124 | (or global-mode-string (setq global-mode-string '(""))) | ||
| 125 | (if on | ||
| 126 | (progn | ||
| 127 | (or (memq 'display-time-string global-mode-string) | ||
| 128 | (setq global-mode-string | ||
| 129 | (append global-mode-string '(display-time-string)))) | ||
| 130 | ;; Set up the time timer. | ||
| 131 | (setq display-time-timer | ||
| 132 | (run-at-time t display-time-interval | ||
| 133 | 'display-time-event-handler)) | ||
| 134 | ;; Make the time appear right away. | ||
| 135 | (display-time-update) | ||
| 136 | ;; When you get new mail, clear "Mail" from the mode line. | ||
| 137 | (add-hook 'rmail-after-get-new-mail-hook | ||
| 138 | 'display-time-event-handler)) | ||
| 139 | (remove-hook 'rmail-after-get-new-mail-hook | ||
| 140 | 'display-time-event-handler)))) | ||
| 141 | |||
| 142 | (defcustom display-time-mail-face 'mode-line | 93 | (defcustom display-time-mail-face 'mode-line |
| 143 | "Face to use for `display-time-mail-string'. | 94 | "Face to use for `display-time-mail-string'. |
| 144 | If `display-time-use-mail-icon' is non-nil, the image's background | 95 | If `display-time-use-mail-icon' is non-nil, the image's background |
| @@ -307,8 +258,36 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'." | |||
| 307 | (and (file-exists-p file) | 258 | (and (file-exists-p file) |
| 308 | (< 0 (nth 7 (file-attributes (file-chase-links file)))))) | 259 | (< 0 (nth 7 (file-attributes (file-chase-links file)))))) |
| 309 | 260 | ||
| 310 | (if display-time-mode | 261 | ;;;###autoload |
| 311 | (display-time-mode t)) | 262 | (define-minor-mode display-time-mode |
| 263 | "Toggle display of time, load level, and mail flag in mode lines. | ||
| 264 | With a numeric arg, enable this display if arg is positive. | ||
| 265 | |||
| 266 | When this display is enabled, it updates automatically every minute. | ||
| 267 | If `display-time-day-and-date' is non-nil, the current day and date | ||
| 268 | are displayed as well. | ||
| 269 | This runs the normal hook `display-time-hook' after each update." | ||
| 270 | nil nil nil :global t :group 'display-time | ||
| 271 | (and display-time-timer (cancel-timer display-time-timer)) | ||
| 272 | (setq display-time-timer nil) | ||
| 273 | (setq display-time-string "") | ||
| 274 | (or global-mode-string (setq global-mode-string '(""))) | ||
| 275 | (if display-time-mode | ||
| 276 | (progn | ||
| 277 | (or (memq 'display-time-string global-mode-string) | ||
| 278 | (setq global-mode-string | ||
| 279 | (append global-mode-string '(display-time-string)))) | ||
| 280 | ;; Set up the time timer. | ||
| 281 | (setq display-time-timer | ||
| 282 | (run-at-time t display-time-interval | ||
| 283 | 'display-time-event-handler)) | ||
| 284 | ;; Make the time appear right away. | ||
| 285 | (display-time-update) | ||
| 286 | ;; When you get new mail, clear "Mail" from the mode line. | ||
| 287 | (add-hook 'rmail-after-get-new-mail-hook | ||
| 288 | 'display-time-event-handler)) | ||
| 289 | (remove-hook 'rmail-after-get-new-mail-hook | ||
| 290 | 'display-time-event-handler))) | ||
| 312 | 291 | ||
| 313 | (provide 'time) | 292 | (provide 'time) |
| 314 | 293 | ||