Mercurial > hg > xemacs-beta
comparison lisp/packages/time.el @ 110:fe104dbd9147 r20-1b7
Import from CVS: tag r20-1b7
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:19:45 +0200 |
parents | 360340f9fd5f |
children | 8619ce7e4c50 |
comparison
equal
deleted
inserted
replaced
109:e183fc049578 | 110:fe104dbd9147 |
---|---|
40 | 40 |
41 ;;; Code: | 41 ;;; Code: |
42 | 42 |
43 (require 'itimer) | 43 (require 'itimer) |
44 | 44 |
45 (defvar display-time-compatible nil | 45 (defgroup display-time nil |
46 "*This variable may be set to nil to get the old behaviour of display-time. | 46 "Facilities to display the current time/date/load and a new-mail indicator |
47 This means no display of a spiffy mail icon or use of the display-time-form-list | 47 in the XEmacs mode line or echo area." |
48 instead of the old display-time-string-form.") | 48 :group 'applications) |
49 | 49 |
50 (defvar display-time-mail-file nil | 50 (defcustom display-time-compatible nil |
51 "*This variable may be set to t to get the old behaviour of display-time. | |
52 This means no display of a spiffy mail icon or use of the | |
53 display-time-form-list instead of the old display-time-string-form." | |
54 :group 'display-time | |
55 :type 'boolean) | |
56 | |
57 (defcustom display-time-mail-file nil | |
51 "*File name of mail inbox file, for indicating existence of new mail. | 58 "*File name of mail inbox file, for indicating existence of new mail. |
52 Non-nil and not a string means don't check for mail. nil means use | 59 Non-nil and not a string means don't check for mail. nil means use |
53 default, which is system-dependent, and is the same as used by Rmail.") | 60 default, which is system-dependent, and is the same as used by Rmail." |
61 :group 'display-time) | |
54 | 62 |
55 ;;;###autoload | 63 ;;;###autoload |
56 (defvar display-time-day-and-date nil "\ | 64 (defcustom display-time-day-and-date nil |
57 *Non-nil means \\[display-time] should display day and date as well as time.") | 65 "*Non-nil means \\[display-time] should display day,date and time. |
58 | 66 This affects the spec 'date in the variable display-time-form-list." |
59 (defvar display-time-interval 20 | 67 :group 'display-time |
60 "*Seconds between updates of time in the mode line.") | 68 :type 'boolean) |
61 | 69 |
62 (defvar display-time-24hr-format nil | 70 (defcustom display-time-interval 20 |
71 "*Seconds between updates of time in the mode line." | |
72 :group 'display-time | |
73 :type 'integer) | |
74 | |
75 (defcustom display-time-24hr-format nil | |
63 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. | 76 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. |
64 Nil means 1 <= hh <= 12, and an AM/PM suffix is used.") | 77 Nil means 1 <= hh <= 12, and an AM/PM suffix is used. |
65 | 78 This affects the spec 'time in the variable display-time-form-list." |
66 (defvar display-time-echo-area nil | 79 :group 'display-time |
67 "*If non-nil, display-time will use the echo area instead of the mode line.") | 80 :type 'boolean) |
81 | |
82 (defcustom display-time-echo-area nil | |
83 "*If non-nil, display-time will use the echo area instead of the mode line." | |
84 :group 'display-time | |
85 :type 'boolean) | |
68 | 86 |
69 (defvar display-time-string nil) | 87 (defvar display-time-string nil) |
70 | 88 |
71 (defvar display-time-hook nil | 89 (defcustom display-time-hook nil |
72 "*List of functions to be called when the time is updated on the mode line.") | 90 "*List of functions to be called when the time is updated on the mode line." |
91 :group 'display-time | |
92 :type 'hook) | |
73 | 93 |
74 (defvar display-time-server-down-time nil | 94 (defvar display-time-server-down-time nil |
75 "Time when mail file's file system was recorded to be down. | 95 "Time when mail file's file system was recorded to be down. |
76 If that file system seems to be up, the value is nil.") | 96 If that file system seems to be up, the value is nil.") |
97 | |
98 (defcustom display-time-ignore-read-mail nil | |
99 "*Non-nil means displays the mail icon on any non-empty mailbox." | |
100 :group 'display-time | |
101 :type 'boolean) | |
77 | 102 |
78 ;;;###autoload | 103 ;;;###autoload |
79 (defun display-time () | 104 (defun display-time () |
80 "Display current time, load level, and mail flag in mode line of each buffer. | 105 "Display current time, load level, and mail flag in mode line of each buffer. |
81 Updates automatically every minute. | 106 Updates automatically every minute. |
114 ;; wake up exactly at the minute boundary. But that's just a little | 139 ;; wake up exactly at the minute boundary. But that's just a little |
115 ;; more work than it's worth... | 140 ;; more work than it's worth... |
116 (start-itimer "display-time" 'display-time-function | 141 (start-itimer "display-time" 'display-time-function |
117 display-time-interval display-time-interval)) | 142 display-time-interval display-time-interval)) |
118 | 143 |
119 (defvar display-time-show-icons-maybe t | 144 (defcustom display-time-show-icons-maybe t |
120 "Use icons to indicate the mail status if possible") | 145 "Use icons for time, load and mail status if possible |
121 | 146 and not specified different explicitely" |
122 (defvar display-time-icons-dir (concat data-directory "time/")) | 147 :group 'display-time |
123 | 148 :type 'boolean) |
124 (defvar display-time-mail-sign-string " Mail" | 149 |
125 "The string used as mail indicator in the echo area | 150 (defvar display-time-icons-dir (concat data-directory "time/")) |
151 | |
152 (defcustom display-time-mail-sign-string " Mail" | |
153 "The string used as mail indicator in the echo area | |
126 (and in the modeline if display-time-show-icons-maybe is nil) | 154 (and in the modeline if display-time-show-icons-maybe is nil) |
127 if display-time-echo-area is t") | 155 if display-time-echo-area is t" |
128 | 156 :group 'display-time |
129 (defvar display-time-no-mail-sign-string "" | 157 :type 'string) |
158 | |
159 (defcustom display-time-no-mail-sign-string "" | |
130 "The string used as no-mail indicator in the echo area | 160 "The string used as no-mail indicator in the echo area |
131 (and in the modeline if display-time-show-icons-maybe is nil) | 161 (and in the modeline if display-time-show-icons-maybe is nil) |
132 if display-time-echo-area is t") | 162 if display-time-echo-area is t" |
133 | 163 :group 'display-time |
134 (defvar display-time-mail-sign | 164 :type 'string) |
135 (progn | 165 |
136 (let* ((file (concat display-time-icons-dir "letter.xpm")) | 166 (defcustom display-time-display-pad t |
137 (glyph (if (featurep 'xpm) (make-glyph file) | 167 "Wether the load indicator is displayed with a trapezoidal \"pad\" |
138 display-time-mail-sign-string)) | 168 in the background" |
139 (ext (make-extent nil nil))) | 169 :group 'display-time |
140 (cons ext glyph))) | 170 :type 'boolean) |
141 "A variable holding a cons cell (ext . glyph) | 171 |
142 which gives an indicator for new mail in the modeline") | 172 (defcustom display-time-load-list |
143 | 173 (list 0.2 0.5 0.8 1.1 1.8 2.6) |
144 (defvar display-time-no-mail-sign | 174 "*A list giving six thresholds for the load |
145 (progn | 175 which correspond to the six different icons to be displayed |
146 (let* ((file (concat display-time-icons-dir "no-letter.xpm")) | 176 as a load indicator" |
147 (glyph (if (featurep 'xpm) (make-glyph file) | 177 :group 'display-time |
148 display-time-no-mail-sign-string)) | 178 :type '(list (number :tag "Threshold 1 load") |
149 (ext (make-extent nil nil))) | 179 (number :tag "Threshold 2 load") |
150 (cons ext glyph))) | 180 (number :tag "Threshold 3 load") |
151 "A variable holding a cons cell (ext . glyph) which gives | 181 (number :tag "Threshold 4 load") |
152 an indicator for `no mail' in the modeline") | 182 (number :tag "Threshold 5 load") |
183 (number :tag "Threshold 6 load"))) | |
153 | 184 |
154 (defun display-time-string-to-char-list (str) | 185 (defun display-time-string-to-char-list (str) |
155 (mapcar (function identity) str)) | 186 (mapcar (function identity) str)) |
156 | 187 |
157 | |
158 (if (featurep 'xpm) | 188 (if (featurep 'xpm) |
159 (progn | 189 (progn |
160 (setq display-time-1-glyph | 190 (defvar display-time-mail-sign |
161 (cons (make-extent nil nil) | 191 (cons (make-extent nil nil) |
162 (make-glyph (concat display-time-icons-dir "1.xpm")))) | 192 (make-glyph (concat display-time-icons-dir "letter.xpm")))) |
163 (setq display-time-2-glyph | 193 (defvar display-time-no-mail-sign |
164 (cons (make-extent nil nil) | 194 (cons (make-extent nil nil) |
165 (make-glyph (concat display-time-icons-dir "2.xpm")))) | 195 (make-glyph (concat display-time-icons-dir "no-letter.xpm")))) |
166 (setq display-time-3-glyph | 196 (defvar display-time-1-glyph |
167 (cons (make-extent nil nil) | 197 (cons (make-extent nil nil) |
168 (make-glyph (concat display-time-icons-dir "3.xpm")))) | 198 (make-glyph (concat display-time-icons-dir "1.xpm")))) |
169 (setq display-time-4-glyph | 199 (defvar display-time-2-glyph |
170 (cons (make-extent nil nil) | 200 (cons (make-extent nil nil) |
171 (make-glyph (concat display-time-icons-dir "4.xpm")))) | 201 (make-glyph (concat display-time-icons-dir "2.xpm")))) |
172 (setq display-time-5-glyph | 202 (defvar display-time-3-glyph |
173 (cons (make-extent nil nil) | 203 (cons (make-extent nil nil) |
174 (make-glyph (concat display-time-icons-dir "5.xpm")))) | 204 (make-glyph (concat display-time-icons-dir "3.xpm")))) |
175 (setq display-time-6-glyph | 205 (defvar display-time-4-glyph |
176 (cons (make-extent nil nil) | 206 (cons (make-extent nil nil) |
177 (make-glyph (concat display-time-icons-dir "6.xpm")))) | 207 (make-glyph (concat display-time-icons-dir "4.xpm")))) |
178 (setq display-time-7-glyph | 208 (defvar display-time-5-glyph |
179 (cons (make-extent nil nil) | 209 (cons (make-extent nil nil) |
180 (make-glyph (concat display-time-icons-dir "7.xpm")))) | 210 (make-glyph (concat display-time-icons-dir "5.xpm")))) |
181 (setq display-time-8-glyph | 211 (defvar display-time-6-glyph |
182 (cons (make-extent nil nil) | 212 (cons (make-extent nil nil) |
183 (make-glyph (concat display-time-icons-dir "8.xpm")))) | 213 (make-glyph (concat display-time-icons-dir "6.xpm")))) |
184 (setq display-time-9-glyph | 214 (defvar display-time-7-glyph |
185 (cons (make-extent nil nil) | 215 (cons (make-extent nil nil) |
186 (make-glyph (concat display-time-icons-dir "9.xpm")))) | 216 (make-glyph (concat display-time-icons-dir "7.xpm")))) |
187 (setq display-time-0-glyph | 217 (defvar display-time-8-glyph |
188 (cons (make-extent nil nil) | 218 (cons (make-extent nil nil) |
189 (make-glyph (concat display-time-icons-dir "0.xpm")))) | 219 (make-glyph (concat display-time-icons-dir "8.xpm")))) |
190 (setq display-time-:-glyph | 220 (defvar display-time-9-glyph |
191 (cons (make-extent nil nil) | 221 (cons (make-extent nil nil) |
192 (make-glyph (concat display-time-icons-dir "dp.xpm")))) | 222 (make-glyph (concat display-time-icons-dir "9.xpm")))) |
193 (setq display-time-load-0.0-glyph | 223 (defvar display-time-0-glyph |
194 (cons (make-extent nil nil) | 224 (cons (make-extent nil nil) |
195 (make-glyph (concat display-time-icons-dir "l-0.0.xpm")))) | 225 (make-glyph (concat display-time-icons-dir "0.xpm")))) |
196 (setq display-time-load-0.5-glyph | 226 (defvar display-time-:-glyph |
197 (cons (make-extent nil nil) | 227 (cons (make-extent nil nil) |
198 (make-glyph (concat display-time-icons-dir "l-0.5.xpm")))) | 228 (make-glyph (concat display-time-icons-dir "dp.xpm")))) |
199 (setq display-time-load-1.0-glyph | 229 (defvar display-time-load-0.0-glyph |
200 (cons (make-extent nil nil) | 230 (cons (make-extent nil nil) |
201 (make-glyph (concat display-time-icons-dir "l-1.0.xpm")))) | 231 (make-glyph (concat display-time-icons-dir "l-0.0.xpm")))) |
202 (setq display-time-load-1.5-glyph | 232 (defvar display-time-load-0.5-glyph |
203 (cons (make-extent nil nil) | 233 (cons (make-extent nil nil) |
204 (make-glyph (concat display-time-icons-dir "l-1.5.xpm")))) | 234 (make-glyph (concat display-time-icons-dir "l-0.5.xpm")))) |
205 (setq display-time-load-2.0-glyph | 235 (defvar display-time-load-1.0-glyph |
206 (cons (make-extent nil nil) | 236 (cons (make-extent nil nil) |
207 (make-glyph (concat display-time-icons-dir "l-2.0.xpm")))) | 237 (make-glyph (concat display-time-icons-dir "l-1.0.xpm")))) |
208 (setq display-time-load-2.5-glyph | 238 (defvar display-time-load-1.5-glyph |
209 (cons (make-extent nil nil) | 239 (cons (make-extent nil nil) |
210 (make-glyph (concat display-time-icons-dir "l-2.5.xpm")))) | 240 (make-glyph (concat display-time-icons-dir "l-1.5.xpm")))) |
211 (setq display-time-load-3.0-glyph | 241 (defvar display-time-load-2.0-glyph |
212 (cons (make-extent nil nil) | 242 (cons (make-extent nil nil) |
213 (make-glyph (concat display-time-icons-dir "l-3.0.xpm")))) | 243 (make-glyph (concat display-time-icons-dir "l-2.0.xpm")))) |
214 (setq display-time-am-glyph | 244 (defvar display-time-load-2.5-glyph |
215 (cons (make-extent nil nil) | 245 (cons (make-extent nil nil) |
216 (make-glyph (concat display-time-icons-dir "am.xpm")))) | 246 (make-glyph (concat display-time-icons-dir "l-2.5.xpm")))) |
217 (setq display-time-pm-glyph | 247 (defvar display-time-load-3.0-glyph |
218 (cons (make-extent nil nil) | 248 (cons (make-extent nil nil) |
219 (make-glyph (concat display-time-icons-dir "pm.xpm")))) | 249 (make-glyph (concat display-time-icons-dir "l-3.0.xpm")))) |
220 )) | 250 (defvar display-time-load-0.0-jtl-glyph |
221 | 251 (cons (make-extent nil nil) |
222 | 252 (make-glyph (concat display-time-icons-dir "l-jtl-0.0.xpm")))) |
223 (defun display-time-convert-num-to-pics (string) | 253 (defvar display-time-load-0.5-jtl-glyph |
224 (let ((list (display-time-string-to-char-list string)) | 254 (cons (make-extent nil nil) |
225 elem result tmp) | 255 (make-glyph (concat display-time-icons-dir "l-jtl-0.5.xpm")))) |
226 (if (not (and display-time-show-icons-maybe | 256 (defvar display-time-load-1.0-jtl-glyph |
227 (eq (console-type) 'x) | 257 (cons (make-extent nil nil) |
228 (not display-time-echo-area))) string | 258 (make-glyph (concat display-time-icons-dir "l-jtl-1.0.xpm")))) |
259 (defvar display-time-load-1.5-jtl-glyph | |
260 (cons (make-extent nil nil) | |
261 (make-glyph (concat display-time-icons-dir "l-jtl-1.5.xpm")))) | |
262 (defvar display-time-load-2.0-jtl-glyph | |
263 (cons (make-extent nil nil) | |
264 (make-glyph (concat display-time-icons-dir "l-jtl-2.0.xpm")))) | |
265 (defvar display-time-load-2.5-jtl-glyph | |
266 (cons (make-extent nil nil) | |
267 (make-glyph (concat display-time-icons-dir "l-jtl-2.5.xpm")))) | |
268 (defvar display-time-load-3.0-jtl-glyph | |
269 (cons (make-extent nil nil) | |
270 (make-glyph (concat display-time-icons-dir "l-jtl-3.0.xpm")))) | |
271 (defvar display-time-am-glyph | |
272 (cons (make-extent nil nil) | |
273 (make-glyph (concat display-time-icons-dir "am.xpm")))) | |
274 (defvar display-time-pm-glyph | |
275 (cons (make-extent nil nil) | |
276 (make-glyph (concat display-time-icons-dir "pm.xpm")))) | |
277 )) | |
278 | |
279 | |
280 (defun display-time-can-do-graphical-display (&optional textual) | |
281 (and display-time-show-icons-maybe | |
282 (not textual) | |
283 (eq (console-type) 'x) | |
284 (featurep 'xpm) | |
285 (not display-time-echo-area))) | |
286 | |
287 | |
288 (defun display-time-convert-num (time-string &optional textual) | |
289 (let ((list (display-time-string-to-char-list time-string)) | |
290 elem tmp) | |
291 (if (not (display-time-can-do-graphical-display textual)) time-string | |
229 (while (setq elem (pop list)) | 292 (while (setq elem (pop list)) |
230 (push (eval (intern-soft (concat "display-time-" | 293 (push (eval (intern-soft (concat "display-time-" |
231 (char-to-string elem) | 294 (char-to-string elem) |
232 "-glyph"))) tmp)) | 295 "-glyph"))) tmp)) |
233 (setq result (reverse tmp))))) | 296 (reverse tmp)))) |
234 | 297 |
235 (defvar display-time-load-list | 298 (defun display-time-convert-load (load-string &optional textual) |
236 (list 0.2 0.5 0.8 1.1 1.8 2.6) | 299 (let ((load-number (string-to-number load-string)) |
237 "*A list giving six thresholds for the load which correspond | |
238 to the six different icons to be displayed as a load indicator") | |
239 | |
240 (defun display-time-convert-load-to-glyph (n) | |
241 (let ((load-number (string-to-number n)) | |
242 (alist (list (cons 0.0 0.0) | 300 (alist (list (cons 0.0 0.0) |
243 (cons 0.5 (car display-time-load-list)) | 301 (cons 0.5 (car display-time-load-list)) |
244 (cons 1.0 (cadr display-time-load-list)) | 302 (cons 1.0 (cadr display-time-load-list)) |
245 (cons 1.5 (caddr display-time-load-list)) | 303 (cons 1.5 (caddr display-time-load-list)) |
246 (cons 2.0 (cadddr display-time-load-list)) | 304 (cons 2.0 (cadddr display-time-load-list)) |
247 (cons 2.5 (cadr (cdddr display-time-load-list))) | 305 (cons 2.5 (cadr (cdddr display-time-load-list))) |
248 (cons 3.0 (caddr (cdddr display-time-load-list))) | 306 (cons 3.0 (caddr (cdddr display-time-load-list))) |
249 (cons 100000 100000))) | 307 (cons 100000 100000))) |
250 result elem) | 308 result elem) |
251 (if (not (and display-time-show-icons-maybe | 309 (if (not (display-time-can-do-graphical-display textual)) |
252 (eq (console-type) 'x) | 310 load-string |
253 (not display-time-echo-area))) n | |
254 (while (>= load-number (cdr (setq elem (pop alist)))) | 311 (while (>= load-number (cdr (setq elem (pop alist)))) |
255 (setq result (eval (intern-soft (concat | 312 (setq result (eval (intern-soft (concat |
256 "display-time-load-" | 313 "display-time-load-" |
257 (number-to-string (car elem)) | 314 (number-to-string (car elem)) |
315 (if display-time-display-pad "-jtl") | |
258 "-glyph"))))) | 316 "-glyph"))))) |
259 result))) | 317 result))) |
260 | 318 |
261 (defun display-time-convert-am-pm (n) | 319 (defun display-time-convert-am-pm (ampm-string &optional textual) |
262 (if (not (and display-time-show-icons-maybe | 320 (if (not (display-time-can-do-graphical-display textual)) |
263 (eq (console-type) 'x) | 321 ampm-string |
264 (not display-time-echo-area))) n | 322 (cond ((equal ampm-string "am") display-time-am-glyph) |
265 (cond ((equal n "am") display-time-am-glyph) | 323 ((equal ampm-string "pm") display-time-pm-glyph)))) |
266 ((equal n "pm") display-time-pm-glyph)))) | 324 |
267 | 325 |
268 | 326 (defun display-time-mail-sign (&optional textual) |
269 (defun display-time-mail-sign () | |
270 "*A function giving back the object indicating 'mail' which | 327 "*A function giving back the object indicating 'mail' which |
271 is the value of display-time-mail-sign when running under X, | 328 is the value of display-time-mail-sign when running under X, |
272 display-time-echo-area is nil and display-time-show-icons-maybe is t. | 329 display-time-echo-area is nil and display-time-show-icons-maybe is t. |
273 It is the value of display-time-mail-sign-string otherwise." | 330 It is the value of display-time-mail-sign-string otherwise." |
274 (if (or (not (eq (console-type) 'x)) | 331 (if (not (display-time-can-do-graphical-display textual)) |
275 display-time-echo-area | |
276 (not display-time-show-icons-maybe)) | |
277 display-time-mail-sign-string | 332 display-time-mail-sign-string |
278 display-time-mail-sign)) | 333 display-time-mail-sign)) |
279 | 334 |
280 (defun display-time-no-mail-sign () | 335 (defun display-time-no-mail-sign (&optional textual) |
281 "*A function giving back the object indicating 'no mail' which | 336 "*A function giving back the object indicating 'no mail' which |
282 is the value of display-time-no-mail-sign when running under X, | 337 is the value of display-time-no-mail-sign when running under X, |
283 display-time-echo-area is nil and display-time-show-icons-maybe is t. | 338 display-time-echo-area is nil and display-time-show-icons-maybe is t. |
284 It is the value of display-time-no-mail-sign-string otherwise." | 339 It is the value of display-time-no-mail-sign-string otherwise." |
285 (if (or (not (eq (console-type) 'x)) | 340 (if (not (display-time-can-do-graphical-display textual)) |
286 display-time-echo-area | |
287 (not display-time-show-icons-maybe)) | |
288 display-time-no-mail-sign-string | 341 display-time-no-mail-sign-string |
289 display-time-no-mail-sign)) | 342 display-time-no-mail-sign)) |
290 | 343 |
291 (defvar display-time-form-list | 344 (defcustom display-time-form-list |
292 (list 'date-compatible 'time-compatible 'load 'mail) | 345 (list 'date 'time 'load 'mail) |
293 "*This list describes the format of the strings/glyphs which are to be | 346 "*This list describes the format of the strings/glyphs |
294 displayed by display-time. The old variable display-time-string-forms is | 347 which are to be displayed by display-time. |
295 only used if display-time-compatible is non-nil. It is a list consisting of | 348 The old variable display-time-string-forms is only used if |
349 display-time-compatible is non-nil. It is a list consisting of | |
296 strings or any of the following symbols: | 350 strings or any of the following symbols: |
297 | 351 |
298 date-compatible: This prints out the date in a manner compatible to | 352 There are three complex specs whose behaviour is changed via |
299 the default value of the obsolete variable | 353 the setting of various variables |
300 display-time-string-forms. It respects the variable | 354 |
301 display-time-day-and-date. If this is t it will print | 355 date: This prints out the date in a manner compatible to |
302 out the current date in the form DAYNAME MONTH DAY | 356 the default value of the obsolete variable |
303 otherwise it will print nothing. | 357 display-time-string-forms. It respects the variable |
304 | 358 display-time-day-and-date. If this is t it will print |
305 time-compatible: This prints out the time in a manner compatible to | 359 out the current date in the form DAYNAME MONTH DAY |
306 the default value of the obsolete variable | 360 otherwise it will print nothing. |
307 display-time-string-forms. It respects the variable | 361 |
308 display-time-24hr-format. If this is t it will print | 362 time: This prints out the time in a manner compatible to |
309 out the current hours in 24-hour format, if nil the | 363 the default value of the obsolete variable |
310 hours will be printed in 12-hour format and the | 364 display-time-string-forms. It respects the variable |
311 minutes will be followed by 'AM' or 'PM'. | 365 display-time-24hr-format. If this is t it will print |
312 | 366 out the current hours in 24-hour format, if nil the |
313 24-hours: This prints the hours in 24-hours format | 367 hours will be printed in 12-hour format and the |
314 | 368 minutes will be followed by 'AM' or 'PM'. |
315 12-hours: This prints the hours in 12-hours format | 369 |
316 | 370 time-text: The same as above, but will not use a glyph |
317 am-pm: This prints Am or Pm. | 371 |
318 | 372 The other specs are simpler, as their meaning is not changed via |
319 dp: This prints a \":\", maybe as an icon | 373 variables. |
320 | 374 |
321 minutes: This prints the minutes. | 375 24-hours: This prints the hours in 24-hours format |
322 | 376 |
323 day: This prints out the current day as a number. | 377 24-hours-text: The same as above, but will not use a glyph |
324 | 378 |
325 dayname: This prints out today's name. | 379 12-hours: This prints the hours in 12-hours format |
326 | 380 |
327 month: This prints out the current month as a number | 381 12-hours-text: The same as above, but will not use a glyph |
328 | 382 |
329 monthname: This prints out the current month's name | 383 am-pm: This prints am or pm. |
330 | 384 |
331 load: This prints out the system's load. | 385 Timezone: This prints out the local timezone |
332 | 386 |
333 mail: This displays a mail indicator. Under X this will | 387 am-pm-text: The same as above, but will not use a glyph |
334 normally be a small icon which changes depending if | 388 |
335 there is new mail or not.") | 389 minutes: This prints the minutes. |
390 | |
391 minutes-text: The same as above, but will not use a glyph | |
392 | |
393 day: This prints out the current day as a number. | |
394 | |
395 dayname: This prints out today's name. | |
396 | |
397 month: This prints out the current month as a number | |
398 | |
399 monthname: This prints out the current month's name | |
400 | |
401 year: This prints out the current year. | |
402 | |
403 load: This prints out the system's load. | |
404 | |
405 load-text: The same as above, but will not use a glyph | |
406 | |
407 mail: This displays a mail indicator. Under X this will | |
408 normally be a small icon which changes depending if | |
409 there is new mail or not. | |
410 | |
411 mail-text: The same as above, but will not use a glyph" | |
412 :group 'display-time | |
413 :type '(repeat (choice :tag "Toggle Symbol/String" | |
414 (const :tag "Date" date) | |
415 (const :tag "Time" time) | |
416 (const :tag "Time (text)" time-text) | |
417 (const :tag "24 hour format" 24-hours) | |
418 (const :tag "24 hour format (text)" 24-hours-text) | |
419 (const :tag "12 hour format" 12-hours) | |
420 (const :tag "12 hour format (text)" 12-hours-text) | |
421 (const :tag "AM/PM indicator" am-pm) | |
422 (const :tag "AM/PM indicator (text)" am-pm-text) | |
423 (const :tag "Timezone" timezone) | |
424 (const :tag "Minutes" minutes) | |
425 (const :tag "Minutes (text)" minutes-text) | |
426 (const :tag "Day" day) | |
427 (const :tag "Dayname" dayname) | |
428 (const :tag "Month" month) | |
429 (const :tag "Monthname" monthname) | |
430 (const :tag "Year" year) | |
431 (const :tag "Load" load) | |
432 (const :tag "Load (text)" load-text) | |
433 (const :tag "Mail sign" mail) | |
434 (const :tag "Mail sign (text)" mail-text) | |
435 (string :tag "String")))) | |
336 | 436 |
337 (defun display-time-evaluate-list () | 437 (defun display-time-evaluate-list () |
338 "Evalute the variable display-time-form-list" | 438 "Evalute the variable display-time-form-list" |
339 (let ((list display-time-form-list) elem tmp result) | 439 (let ((list display-time-form-list) elem tmp result) |
340 (while (setq elem (pop list)) | 440 (while (setq elem (pop list)) |
341 (cond ((stringp elem) (push elem tmp)) | 441 (cond ((stringp elem) (push elem tmp)) |
342 ((eq elem 'date-compatible) | 442 ((eq elem 'date) |
343 (push (if display-time-day-and-date | 443 (push (if display-time-day-and-date |
344 (format "%s %s %s " dayname monthname day) "") tmp)) | 444 (format "%s %s %s " dayname monthname day) "") tmp)) |
345 ((eq elem 'time-compatible) | 445 ((eq elem 'time) |
346 (progn | 446 (progn |
347 (push (display-time-convert-num-to-pics | 447 (push (display-time-convert-num |
348 (format "%s:%s" | 448 (format "%s:%s" |
349 (if display-time-24hr-format 24-hours 12-hours) | 449 (if display-time-24hr-format 24-hours 12-hours) |
350 minutes)) tmp) | 450 minutes)) tmp) |
351 (if (not display-time-24hr-format) | 451 (if (not display-time-24hr-format) |
352 (push (display-time-convert-am-pm am-pm) tmp)))) | 452 (push (display-time-convert-am-pm am-pm) tmp)))) |
453 ((eq elem 'time-text) | |
454 (push (display-time-convert-num | |
455 (format "%s:%s" | |
456 (if display-time-24hr-format 24-hours 12-hours) | |
457 minutes) t) tmp) | |
458 (if (not display-time-24hr-format) | |
459 (push (display-time-convert-am-pm am-pm t) tmp))) | |
353 ((eq elem 'day) (push day tmp)) | 460 ((eq elem 'day) (push day tmp)) |
354 ((eq elem 'dayname) (push dayname tmp)) | 461 ((eq elem 'dayname) (push dayname tmp)) |
355 ((eq elem 'month) (push month tmp)) | 462 ((eq elem 'month) (push month tmp)) |
356 ((eq elem 'monthname) (push monthname tmp)) | 463 ((eq elem 'monthname) (push monthname tmp)) |
357 ((eq elem '24-hours) (push (display-time-convert-num-to-pics 24-hours) | 464 ((eq elem '24-hours) |
358 tmp)) | 465 (push (display-time-convert-num 24-hours) tmp)) |
359 ((eq elem '12-hours) (push (display-time-convert-num-to-pics 12-hours) | 466 ((eq elem 'year) |
360 tmp)) | 467 (push year tmp)) |
361 ((eq elem 'minutes) (push (display-time-convert-num-to-pics minutes) | 468 ((eq elem '24-hours-text) |
362 tmp)) | 469 (push (display-time-convert-num 24-hours t) tmp)) |
363 ((eq elem 'am-pm) (push am-pm tmp)) | 470 ((eq elem '12-hours) |
364 ((eq elem 'dp) (push (display-time-convert-num-to-pics ":") tmp)) | 471 (push (display-time-convert-num 12-hours) tmp)) |
472 ((eq elem '12-hours-text) | |
473 (push (display-time-convert-num 12-hours t) tmp)) | |
474 ((eq elem 'minutes) | |
475 (push (display-time-convert-num minutes) tmp)) | |
476 ((eq elem 'minutes-text) | |
477 (push (display-time-convert-num minutes t) tmp)) | |
478 ((eq elem 'am-pm) | |
479 (push (display-time-convert-am-pm am-pm) tmp)) | |
480 ((eq elem 'am-pm-text) | |
481 (push (display-time-convert-am-pm am-pm t) tmp)) | |
482 ((eq elem 'timezone) | |
483 (push time-zone tmp)) | |
365 ((eq elem 'load) | 484 ((eq elem 'load) |
366 (push (display-time-convert-load-to-glyph load) tmp)) | 485 (push (display-time-convert-load load) tmp)) |
367 ((eq elem 'mail) (push (if mail (display-time-mail-sign) | 486 ((eq elem 'load-text) |
368 (display-time-no-mail-sign)) | 487 (push (display-time-convert-load load t) tmp)) |
369 tmp)))) | 488 ((eq elem 'mail) |
489 (push (if mail (display-time-mail-sign) | |
490 (display-time-no-mail-sign)) tmp)) | |
491 ((eq elem 'mail-text) | |
492 (push (if mail (display-time-mail-sign t) | |
493 (display-time-no-mail-sign t)) tmp)) | |
494 )) | |
370 ;; We know that we have a list containing only of strings if | 495 ;; We know that we have a list containing only of strings if |
371 ;; display-time-echo-area is t. So we construct this string from | 496 ;; display-time-echo-area is t. So we construct this string from |
372 ;; the list. Else we just reverse the list and give it as result. | 497 ;; the list. Else we just reverse the list and give it as result. |
373 (if (not display-time-echo-area) (setq result (reverse tmp)) | 498 (if (not display-time-echo-area) (setq result (reverse tmp)) |
374 (while (setq elem (pop tmp)) | 499 (while (setq elem (pop tmp)) |
459 ;; don't stomp echo-area-buffer if reading from minibuffer now. | 584 ;; don't stomp echo-area-buffer if reading from minibuffer now. |
460 (save-excursion | 585 (save-excursion |
461 (save-window-excursion | 586 (save-window-excursion |
462 (select-window (minibuffer-window)) | 587 (select-window (minibuffer-window)) |
463 (erase-buffer) | 588 (erase-buffer) |
464 (indent-to (- (screen-width) (length display-time-string) 1)) | 589 (indent-to (- (frame-width) (length display-time-string) 1)) |
465 (insert display-time-string) | 590 (insert display-time-string) |
466 (message (buffer-string))))) | 591 (message (buffer-string))))) |
467 (force-mode-line-update) | 592 (force-mode-line-update) |
468 ;; Do redisplay right now, if no input pending. | 593 ;; Do redisplay right now, if no input pending. |
469 (sit-for 0))) | 594 (sit-for 0))) |
470 | 595 |
471 (defun display-time-file-nonempty-p (file) | 596 (defun display-time-file-nonempty-p (file) |
472 (and (file-exists-p file) | 597 (let ((attributes (file-attributes (file-chase-links file)))) |
473 (< 0 (nth 7 (file-attributes (file-chase-links file)))))) | 598 (and attributes |
599 (< 0 (nth 7 attributes)) | |
600 (or display-time-ignore-read-mail | |
601 (> (car (nth 5 attributes)) (car (nth 4 attributes))) | |
602 (and (= (car (nth 5 attributes)) (car (nth 4 attributes))) | |
603 (> (cadr (nth 5 attributes)) (cadr (nth 4 attributes)))))))) | |
474 | 604 |
475 (provide 'time) | 605 (provide 'time) |
476 | 606 |
477 ;;; time.el ends here | 607 ;;; time.el ends here |