Mercurial > emacs
comparison lisp/time.el @ 31980:ceb42baae241
(display-time-mode): Use define-minor-mode.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 29 Sep 2000 03:26:00 +0000 |
parents | 1030e638c8dd |
children | 5ddf69eeb2bb |
comparison
equal
deleted
inserted
replaced
31979:6085a3297ebc | 31980:ceb42baae241 |
---|---|
30 | 30 |
31 (defgroup display-time nil | 31 (defgroup display-time nil |
32 "Display time and load in mode line of Emacs." | 32 "Display time and load in mode line of Emacs." |
33 :group 'modeline | 33 :group 'modeline |
34 :group 'mail) | 34 :group 'mail) |
35 | |
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 | 35 |
50 | 36 |
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 |
101 If `display-time-day-and-date' is non-nil, the current day and date | 87 If `display-time-day-and-date' is non-nil, the current day and date |
102 are displayed as well. | 88 are displayed as well. |
103 This runs the normal hook `display-time-hook' after each update." | 89 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 | |
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 | 92 |
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 |
145 colour is the background of this face. Set this to a face other than | 96 colour is the background of this face. Set this to a face other than |
305 | 256 |
306 (defun display-time-file-nonempty-p (file) | 257 (defun display-time-file-nonempty-p (file) |
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 |
315 ;;; time.el ends here | 294 ;;; time.el ends here |