0
|
1 ;;; time.el --- display time and load in mode line of Emacs.
|
|
2
|
2
|
3 ;; Copyright (C) 1985, 86, 87, 93, 94, 1996 Free Software Foundation, Inc.
|
0
|
4
|
118
|
5 ;; Maintainer: FSF for the original version.
|
|
6 ;; XEmacs add-ons and rewrite (C) by Jens Lautenbacher
|
|
7 ;; mail <jens@lemming0.lem.uni-karlsruhe.de>
|
|
8 ;; for comments/fixes about the enhancements.
|
0
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
2
|
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
25 ;; 02111-1307, USA.
|
0
|
26
|
118
|
27 ;;; Version: 1.13 (I choose the version number starting at 1.1
|
116
|
28 ;;; to indicate that 1.0 was the old version
|
|
29 ;;; before I hacked away on it -jtl)
|
|
30
|
2
|
31 ;;; Synched up with: Not synched with FSF.
|
0
|
32
|
|
33 ;;; Commentary:
|
|
34
|
2
|
35 ;; Facilities to display current time/date and a new-mail indicator
|
|
36 ;; in the Emacs mode line. The single entry point is `display-time'.
|
0
|
37
|
2
|
38 ;; See also reportmail.el.
|
|
39 ;; This uses the XEmacs timeout-event mechanism, via a version
|
|
40 ;; of Kyle Jones' itimer package.
|
0
|
41
|
116
|
42 ;;; jtl: This is in a wide part reworked for XEmacs so it won't use
|
108
|
43 ;;; the old mechanism for specifying what is to be displayed.
|
|
44 ;;; The starting variable to look at is `display-time-form-list'
|
|
45
|
116
|
46 ;;; It's more advanced features include heavy use of `balloon-help' a
|
|
47 ;;; package again written by Kyle Jones. You need to load this
|
|
48 ;;; explicitely on your own because I don't think a package should make
|
|
49 ;;; decisions which have a global effect (if you want to use it, a
|
|
50 ;;; (require 'balloon-help) in your .emacs should work. But look at the
|
|
51 ;;; documentation in balloon-help.el itself).
|
|
52
|
114
|
53 ;;; Thanks to Mike Scheidler for the idea to make the time led's fore- and
|
|
54 ;;; background color customizable
|
|
55
|
0
|
56 ;;; Code:
|
|
57
|
|
58 (require 'itimer)
|
|
59
|
118
|
60 (defconst display-time-version-number "1.13" "Version number of time.el")
|
|
61 (defconst display-time-version (format "Time.el version %s for XEmacs"
|
|
62 display-time-version-number)
|
|
63 "The full version string for time.el")
|
|
64
|
110
|
65 (defgroup display-time nil
|
|
66 "Facilities to display the current time/date/load and a new-mail indicator
|
|
67 in the XEmacs mode line or echo area."
|
|
68 :group 'applications)
|
108
|
69
|
118
|
70 (defgroup display-time-balloon nil
|
|
71 "Fancy add-ons to display-time for using the `balloon-help' feature.
|
|
72 balloon-help must be loaded before these settings take effect."
|
|
73 :group 'display-time)
|
|
74
|
|
75
|
110
|
76 (defcustom display-time-mail-file nil
|
0
|
77 "*File name of mail inbox file, for indicating existence of new mail.
|
|
78 Non-nil and not a string means don't check for mail. nil means use
|
110
|
79 default, which is system-dependent, and is the same as used by Rmail."
|
|
80 :group 'display-time)
|
0
|
81
|
|
82 ;;;###autoload
|
110
|
83 (defcustom display-time-day-and-date nil
|
|
84 "*Non-nil means \\[display-time] should display day,date and time.
|
|
85 This affects the spec 'date in the variable display-time-form-list."
|
|
86 :group 'display-time
|
|
87 :type 'boolean)
|
0
|
88
|
110
|
89 (defcustom display-time-interval 20
|
|
90 "*Seconds between updates of time in the mode line."
|
|
91 :group 'display-time
|
|
92 :type 'integer)
|
0
|
93
|
110
|
94 (defcustom display-time-24hr-format nil
|
0
|
95 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23.
|
110
|
96 Nil means 1 <= hh <= 12, and an AM/PM suffix is used.
|
|
97 This affects the spec 'time in the variable display-time-form-list."
|
|
98 :group 'display-time
|
|
99 :type 'boolean)
|
0
|
100
|
110
|
101 (defcustom display-time-echo-area nil
|
|
102 "*If non-nil, display-time will use the echo area instead of the mode line."
|
|
103 :group 'display-time
|
|
104 :type 'boolean)
|
0
|
105
|
|
106 (defvar display-time-string nil)
|
|
107
|
110
|
108 (defcustom display-time-hook nil
|
|
109 "*List of functions to be called when the time is updated on the mode line."
|
|
110 :group 'display-time
|
|
111 :type 'hook)
|
0
|
112
|
|
113 (defvar display-time-server-down-time nil
|
|
114 "Time when mail file's file system was recorded to be down.
|
|
115 If that file system seems to be up, the value is nil.")
|
|
116
|
116
|
117 (defcustom display-time-ignore-read-mail t
|
|
118 "*Non-nil means display the mail icon on any non-empty mailbox."
|
110
|
119 :group 'display-time
|
|
120 :type 'boolean)
|
|
121
|
0
|
122 ;;;###autoload
|
|
123 (defun display-time ()
|
|
124 "Display current time, load level, and mail flag in mode line of each buffer.
|
|
125 Updates automatically every minute.
|
|
126 If `display-time-day-and-date' is non-nil, the current day and date
|
|
127 are displayed as well.
|
|
128 After each update, `display-time-hook' is run with `run-hooks'.
|
|
129 If `display-time-echo-area' is non-nil, the time is displayed in the
|
|
130 echo area instead of in the mode-line."
|
|
131 (interactive)
|
|
132 ;; if the "display-time" itimer already exists, nuke it first.
|
|
133 (let ((old (get-itimer "display-time")))
|
|
134 (if old (delete-itimer old)))
|
108
|
135
|
|
136 (if (memq 'display-time-string global-mode-string)
|
|
137 (setq global-mode-string
|
|
138 (remove 'display-time-string global-mode-string)))
|
0
|
139 ;; If we're not displaying the time in the echo area
|
|
140 ;; and the global mode string does not have a non-nil value
|
|
141 ;; then initialize the global mode string's value.
|
|
142 (or display-time-echo-area
|
|
143 global-mode-string
|
|
144 (setq global-mode-string '("")))
|
|
145 ;; If we're not displaying the time in the echo area
|
108
|
146 ;; then we add our variable to the list. This will make the time
|
0
|
147 ;; appear on the modeline.
|
|
148 (or display-time-echo-area
|
|
149 (setq global-mode-string
|
108
|
150 (append global-mode-string '(display-time-string))))
|
0
|
151 ;; Display the time initially...
|
|
152 (display-time-function)
|
|
153 ;; ... and start an itimer to do it automatically thereafter.
|
|
154 ;;
|
|
155 ;; If we wanted to be really clever about this, we could have the itimer
|
|
156 ;; not be automatically restarted, but have it re-add itself each time.
|
|
157 ;; Then we could look at (current-time) and arrange for the itimer to
|
|
158 ;; wake up exactly at the minute boundary. But that's just a little
|
|
159 ;; more work than it's worth...
|
|
160 (start-itimer "display-time" 'display-time-function
|
|
161 display-time-interval display-time-interval))
|
|
162
|
114
|
163 (defun display-time-stop ()
|
|
164 (interactive)
|
|
165 (delete-itimer "display-time")
|
|
166 (setq display-time-string nil))
|
|
167
|
110
|
168 (defcustom display-time-show-icons-maybe t
|
|
169 "Use icons for time, load and mail status if possible
|
|
170 and not specified different explicitely"
|
|
171 :group 'display-time
|
|
172 :type 'boolean)
|
104
|
173
|
116
|
174 (defvar display-time-icons-dir (concat data-directory "time/"))
|
104
|
175
|
110
|
176 (defcustom display-time-mail-sign-string " Mail"
|
|
177 "The string used as mail indicator in the echo area
|
108
|
178 (and in the modeline if display-time-show-icons-maybe is nil)
|
110
|
179 if display-time-echo-area is t"
|
|
180 :group 'display-time
|
|
181 :type 'string)
|
104
|
182
|
116
|
183 (defcustom display-time-no-mail-sign-string ""
|
108
|
184 "The string used as no-mail indicator in the echo area
|
|
185 (and in the modeline if display-time-show-icons-maybe is nil)
|
110
|
186 if display-time-echo-area is t"
|
|
187 :group 'display-time
|
|
188 :type 'string)
|
|
189
|
114
|
190 (defcustom display-time-display-pad "grey35"
|
|
191 "How the load indicator's trapezoidal \"pad\" is to be displayed.
|
|
192 This can be 'transparent or a string describing the color it should have"
|
|
193 :group 'display-time
|
|
194 :type '(choice :tag "Value"
|
|
195 (const transparent)
|
|
196 (string :tag "Color")))
|
|
197
|
|
198 (defcustom display-time-display-time-foreground "firebrick"
|
|
199 "How the time LEDs foreground is to be displayed.
|
|
200 This can be 'modeline (foreground color of the Modeline)
|
|
201 or a string describing the color it should have"
|
110
|
202 :group 'display-time
|
114
|
203 :type '(choice :tag "Value"
|
|
204 (const modline)
|
|
205 (string :tag "Color")))
|
|
206
|
|
207 (defcustom display-time-display-time-background 'transparent
|
|
208 "How the time LEDs background is to be displayed.
|
|
209 This can be 'transparent or a string describing the color it should have"
|
|
210 :group 'display-time
|
|
211 :type '(choice :tag "Value"
|
|
212 (const transparent)
|
|
213 (string :tag "Color")))
|
|
214
|
116
|
215 (defcustom display-time-mail-balloon 'display-time-mail-balloon
|
|
216 "What to use to generate the ballon frame of the \"mail\" glyph
|
|
217 if balloon-help is loaded. This can be the function
|
|
218 display-time-mail-balloon, nil or a string."
|
118
|
219 :group 'display-time-balloon
|
116
|
220 :type '(choice (const display-time-mail-balloon)
|
|
221 (const nil)
|
|
222 (string)))
|
|
223
|
|
224 (defcustom display-time-no-mail-balloon "No mail is good mail."
|
|
225 "The string used in the ballon frame of the \"no mail\" glyph
|
|
226 if balloon-help is loaded. This can also be nil"
|
118
|
227 :group 'display-time-balloon
|
116
|
228 :type '(choice (const nil)
|
|
229 (string)))
|
|
230
|
|
231 (defcustom display-time-mail-balloon-show-gnus-group nil
|
|
232 "Show the mail group gnus would put this message in.
|
|
233 This is only useful if you use gnus to read your mail and have set the variable
|
|
234 nnmail-split-methods to split your incoming mail into different groups.
|
|
235 Look at the documentation for gnus. If you don't know what we're talking about,
|
|
236 don't care and leave this set to nil"
|
118
|
237 :group 'display-time-balloon
|
116
|
238 :type 'boolean)
|
|
239
|
|
240 (defface display-time-mail-balloon-enhance-face '((t (:background "orange")))
|
|
241 "Face used for entries in the mail balloon which match the regexp
|
|
242 display-time-mail-balloon-enhance"
|
118
|
243 :group 'display-time-balloon)
|
116
|
244
|
|
245 (defface display-time-mail-balloon-gnus-group-face '((t (:foreground "blue")))
|
|
246 "Face used for the gnus group entry in the mail balloon
|
|
247 if display-time-mail-balloon-show-gnus-group is t (see the documentation there
|
|
248 before you set it to t)"
|
118
|
249 :group 'display-time-balloon)
|
116
|
250
|
|
251 (defcustom display-time-mail-balloon-max-displayed 10
|
|
252 "The maximum number of messaged which are displayed in the mail balloon.
|
|
253 You need to have balloon-help loaded to use this."
|
118
|
254 :group 'display-time-balloon
|
116
|
255 :type 'number)
|
|
256
|
|
257 (defcustom display-time-mail-balloon-from-width 20
|
|
258 "The width of the `From:' part of the mail balloon.
|
|
259 You need to have ballon-help loaded to use this"
|
118
|
260 :group 'display-time-balloon
|
116
|
261 :type 'number)
|
|
262
|
|
263 (defcustom display-time-mail-balloon-subject-width 25
|
|
264 "The width of the `Subject:' part of the mail balloon.
|
|
265 You need to have ballon-help loaded to use this"
|
118
|
266 :group 'display-time-balloon
|
116
|
267 :type 'number)
|
|
268
|
|
269 (defcustom display-time-mail-balloon-gnus-split-width 10
|
|
270 "The width of the `Gnus Mail Group' part of the mail balloon.
|
|
271 This denotes the mail group gnus would decide to put this message in.
|
|
272 For getting this information, it consults the relevant variables from gnus
|
|
273 (nnmail-split-methods).
|
|
274 You need to have ballon-help loaded to use this"
|
118
|
275 :group 'display-time-balloon
|
116
|
276 :type 'number)
|
|
277
|
|
278 (defcustom display-time-mail-balloon-enhance nil
|
|
279 "A list of regular expressions describing which messages should be highlighted
|
|
280 in the mail balloon. The regexp will be matched against the complete header block
|
|
281 of an email. You need to load balloon-help to use this"
|
118
|
282 :group 'display-time-balloon
|
116
|
283 :type '(repeat (string :tag "Regexp")))
|
|
284
|
|
285 (defcustom display-time-mail-balloon-suppress nil
|
|
286 "A list of regular expressions describing which messages should be completely suppressed
|
|
287 in the mail balloon. The regexp will be matched against the complete header block
|
|
288 of an email. It will only take effect if the message is not matched already
|
|
289 by display-time-mail-balloon-enhance.
|
|
290 You need to load balloon-help to use this"
|
118
|
291 :group 'display-time-balloon
|
116
|
292 :type '(repeat (string :tag "Regexp")))
|
|
293
|
|
294 (defcustom display-time-mail-balloon-enhance-gnus-group nil
|
|
295 "A list of regular expressions describing which messages should be highlighted
|
|
296 in the mail balloon. The regexp will be matched against the group gnus would stuff
|
|
297 this message into. It will only take effect if the message is not matched already
|
|
298 by display-time-mail-balloon-suppress.
|
|
299
|
|
300 This requires display-time-mail-balloon-show-gnus-group to be t
|
|
301 and balloon-help to be loaded"
|
118
|
302 :group 'display-time-balloon
|
116
|
303 :type '(repeat (string :tag "Regexp")))
|
|
304
|
|
305 (defcustom display-time-mail-balloon-suppress-gnus-group nil
|
|
306 "A list of regular expressions describing which messages should be completely suppressed
|
|
307 in the mail balloon. The regexp will be matched against the group gnus would stuff
|
|
308 this message into. It will only take effect if the message is not matched already
|
|
309 by display-time-mail-balloon-enhance or display-time-mail-balloon-enhance-gnus-group.
|
|
310
|
|
311 This requires display-time-mail-balloon-show-gnus-group to be t
|
|
312 and balloon-help to be loaded"
|
118
|
313 :group 'display-time-balloon
|
116
|
314 :type '(repeat (string :tag "Regexp")))
|
|
315
|
|
316 (defvar display-time-spool-file-modification nil)
|
|
317
|
|
318 (defvar display-time-mail-header nil)
|
|
319
|
|
320 (defvar display-time-temp-buffer " *Display-time-temp-buffer*")
|
114
|
321
|
|
322 (defvar display-time-display-pad-old nil)
|
|
323
|
|
324 (defvar display-time-display-time-fg-old nil)
|
|
325
|
|
326 (defvar display-time-display-time-bg-old nil)
|
104
|
327
|
110
|
328 (defcustom display-time-load-list
|
|
329 (list 0.2 0.5 0.8 1.1 1.8 2.6)
|
|
330 "*A list giving six thresholds for the load
|
|
331 which correspond to the six different icons to be displayed
|
|
332 as a load indicator"
|
|
333 :group 'display-time
|
114
|
334 :type '(list (number :tag "Threshold 1")
|
|
335 (number :tag "Threshold 2")
|
|
336 (number :tag "Threshold 3")
|
|
337 (number :tag "Threshold 4")
|
|
338 (number :tag "Threshold 5")
|
|
339 (number :tag "Threshold 6")))
|
108
|
340
|
116
|
341 (defcustom display-time-compatible nil
|
|
342 "*This variable may be set to t to get the old behaviour of display-time.
|
|
343 It should be considered obsolete and only be used if you really want the
|
|
344 old behaviour (eq. you made extensive customizations yourself).
|
|
345 This means no display of a spiffy mail icon or use of the
|
|
346 display-time-form-list instead of the old display-time-string-form."
|
|
347 :group 'display-time
|
|
348 :type 'boolean)
|
|
349
|
108
|
350 (defun display-time-string-to-char-list (str)
|
|
351 (mapcar (function identity) str))
|
|
352
|
114
|
353 (defun display-time-generate-load-glyphs (&optional force)
|
|
354 (let* ((pad-color (if (symbolp display-time-display-pad)
|
|
355 (list "pad-color" '(face-background 'modeline))
|
|
356 (list "pad-color" display-time-display-pad)))
|
|
357 (xpm-color-symbols (append (list pad-color) xpm-color-symbols)))
|
|
358 (if (and (featurep 'xpm)
|
|
359 (or force (not (equal display-time-display-pad
|
|
360 display-time-display-pad-old))))
|
|
361 (progn
|
|
362 (setq display-time-load-0.0-glyph
|
|
363 (cons (make-extent nil nil)
|
|
364 (make-glyph
|
|
365 (concat display-time-icons-dir "l-0.0.xpm"))))
|
|
366 (setq display-time-load-0.5-glyph
|
|
367 (cons (make-extent nil nil)
|
|
368 (make-glyph
|
|
369 (concat display-time-icons-dir "l-0.5.xpm"))))
|
|
370 (setq display-time-load-1.0-glyph
|
|
371 (cons (make-extent nil nil)
|
|
372 (make-glyph
|
|
373 (concat display-time-icons-dir "l-1.0.xpm"))))
|
|
374 (setq display-time-load-1.5-glyph
|
|
375 (cons (make-extent nil nil)
|
|
376 (make-glyph
|
|
377 (concat display-time-icons-dir "l-1.5.xpm"))))
|
|
378 (setq display-time-load-2.0-glyph
|
|
379 (cons (make-extent nil nil)
|
|
380 (make-glyph
|
|
381 (concat display-time-icons-dir "l-2.0.xpm"))))
|
|
382 (setq display-time-load-2.5-glyph
|
|
383 (cons (make-extent nil nil)
|
|
384 (make-glyph
|
|
385 (concat display-time-icons-dir "l-2.5.xpm"))))
|
|
386 (setq display-time-load-3.0-glyph
|
|
387 (cons (make-extent nil nil)
|
|
388 (make-glyph
|
|
389 (concat display-time-icons-dir "l-3.0.xpm"))))
|
|
390 (setq display-time-display-pad-old display-time-display-pad)
|
|
391 ))))
|
|
392
|
|
393
|
|
394 (defun display-time-generate-time-glyphs (&optional force)
|
|
395 (let* ((ledbg (if (symbolp display-time-display-time-background)
|
|
396 (list "ledbg" '(face-background 'modeline))
|
|
397 (list "ledbg" display-time-display-time-background)))
|
|
398 (ledfg (if (symbolp display-time-display-time-foreground)
|
|
399 (list "ledfg" '(face-foreground 'modeline))
|
|
400 (list "ledfg" display-time-display-time-foreground)))
|
|
401 (xpm-color-symbols (append (list ledbg)
|
|
402 (list ledfg) xpm-color-symbols)))
|
|
403 (if (and (featurep 'xpm)
|
|
404 (or force (not (equal display-time-display-time-background
|
|
405 display-time-display-time-bg-old))
|
|
406 (not (equal display-time-display-time-foreground
|
|
407 display-time-display-time-fg-old))))
|
|
408 (progn
|
116
|
409 (setq display-time-1-glyph
|
|
410 (cons (make-extent nil nil)
|
114
|
411 (make-glyph (concat display-time-icons-dir "1.xpm"))))
|
|
412 (setq display-time-2-glyph
|
|
413 (cons (make-extent nil nil)
|
|
414 (make-glyph (concat display-time-icons-dir "2.xpm"))))
|
|
415 (setq display-time-3-glyph
|
|
416 (cons (make-extent nil nil)
|
|
417 (make-glyph (concat display-time-icons-dir "3.xpm"))))
|
|
418 (setq display-time-4-glyph
|
|
419 (cons (make-extent nil nil)
|
|
420 (make-glyph (concat display-time-icons-dir "4.xpm"))))
|
|
421 (setq display-time-5-glyph
|
|
422 (cons (make-extent nil nil)
|
|
423 (make-glyph (concat display-time-icons-dir "5.xpm"))))
|
|
424 (setq display-time-6-glyph
|
|
425 (cons (make-extent nil nil)
|
|
426 (make-glyph (concat display-time-icons-dir "6.xpm"))))
|
|
427 (setq display-time-7-glyph
|
|
428 (cons (make-extent nil nil)
|
|
429 (make-glyph (concat display-time-icons-dir "7.xpm"))))
|
|
430 (setq display-time-8-glyph
|
|
431 (cons (make-extent nil nil)
|
|
432 (make-glyph (concat display-time-icons-dir "8.xpm"))))
|
|
433 (setq display-time-9-glyph
|
|
434 (cons (make-extent nil nil)
|
|
435 (make-glyph (concat display-time-icons-dir "9.xpm"))))
|
|
436 (setq display-time-0-glyph
|
|
437 (cons (make-extent nil nil)
|
|
438 (make-glyph (concat display-time-icons-dir "0.xpm"))))
|
|
439 (setq display-time-:-glyph
|
|
440 (cons (make-extent nil nil)
|
|
441 (make-glyph (concat display-time-icons-dir "dp.xpm"))))
|
|
442 (setq display-time-am-glyph
|
|
443 (cons (make-extent nil nil)
|
|
444 (make-glyph (concat display-time-icons-dir "am.xpm"))))
|
|
445 (setq display-time-pm-glyph
|
|
446 (cons (make-extent nil nil)
|
|
447 (make-glyph (concat display-time-icons-dir "pm.xpm"))))
|
|
448 (setq display-time-display-time-fg-old
|
|
449 display-time-display-time-foreground
|
|
450 display-time-display-time-bg-old
|
|
451 display-time-display-time-background)
|
|
452 ))))
|
|
453
|
118
|
454 (defun display-time-init-glyphs ()
|
|
455 "This is a hack to have all glyphs be displayed one time at startup.
|
|
456 It helps avoiding problems with the background color of the glyphs if a
|
|
457 balloon-help frame is open and a not yet displayed glyph is going to be
|
|
458 displayed."
|
|
459 (let ((i 0)
|
|
460 (list '("am" "pm" ":"))
|
|
461 elem mlist)
|
|
462 (while (< i 10)
|
|
463 (push (eval (intern-soft (concat "display-time-"
|
|
464 (number-to-string i)
|
|
465 "-glyph"))) mlist)
|
|
466 (setq i (1+ i)))
|
|
467 (setq i 0.0)
|
|
468 (while (<= i 3.0)
|
|
469 (push (eval (intern-soft (concat "display-time-load-"
|
|
470 (number-to-string i)
|
|
471 "-glyph"))) mlist)
|
|
472 (setq i (+ i 0.5)))
|
|
473 (while (setq elem (pop list))
|
|
474 (push (eval (intern-soft (concat "display-time-"
|
|
475 elem "-glyph"))) mlist))
|
|
476 (let ((global-mode-string mlist))
|
|
477 (redisplay-frame))
|
|
478 ))
|
|
479
|
|
480 (if (featurep 'xpm)
|
108
|
481 (progn
|
110
|
482 (defvar display-time-mail-sign
|
|
483 (cons (make-extent nil nil)
|
114
|
484 (make-glyph (concat display-time-icons-dir "letter.xpm"))))
|
116
|
485 (set-extent-property (car display-time-mail-sign) 'balloon-help
|
|
486 'display-time-mail-balloon)
|
110
|
487 (defvar display-time-no-mail-sign
|
|
488 (cons (make-extent nil nil)
|
114
|
489 (make-glyph (concat display-time-icons-dir "no-letter.xpm"))))
|
116
|
490 (set-extent-property (car display-time-no-mail-sign) 'balloon-help
|
|
491 display-time-no-mail-balloon)
|
114
|
492 (defvar display-time-1-glyph nil)
|
|
493 (defvar display-time-2-glyph nil)
|
|
494 (defvar display-time-3-glyph nil)
|
|
495 (defvar display-time-4-glyph nil)
|
|
496 (defvar display-time-5-glyph nil)
|
|
497 (defvar display-time-6-glyph nil)
|
|
498 (defvar display-time-7-glyph nil)
|
|
499 (defvar display-time-8-glyph nil)
|
|
500 (defvar display-time-9-glyph nil)
|
|
501 (defvar display-time-0-glyph nil)
|
|
502 (defvar display-time-:-glyph nil)
|
|
503 (defvar display-time-am-glyph nil)
|
|
504 (defvar display-time-pm-glyph nil)
|
|
505 (defvar display-time-load-0.0-glyph nil)
|
|
506 (defvar display-time-load-0.5-glyph nil)
|
|
507 (defvar display-time-load-1.0-glyph nil)
|
|
508 (defvar display-time-load-1.5-glyph nil)
|
|
509 (defvar display-time-load-2.0-glyph nil)
|
|
510 (defvar display-time-load-2.5-glyph nil)
|
|
511 (defvar display-time-load-3.0-glyph nil)
|
|
512 (display-time-generate-time-glyphs 'force)
|
|
513 (display-time-generate-load-glyphs 'force)
|
118
|
514 (display-time-init-glyphs)
|
110
|
515 ))
|
104
|
516
|
118
|
517
|
110
|
518 (defun display-time-can-do-graphical-display (&optional textual)
|
|
519 (and display-time-show-icons-maybe
|
|
520 (not textual)
|
|
521 (eq (console-type) 'x)
|
|
522 (featurep 'xpm)
|
|
523 (not display-time-echo-area)))
|
|
524
|
|
525
|
|
526 (defun display-time-convert-num (time-string &optional textual)
|
|
527 (let ((list (display-time-string-to-char-list time-string))
|
116
|
528 elem tmp balloon-help balloon-ext)
|
110
|
529 (if (not (display-time-can-do-graphical-display textual)) time-string
|
114
|
530 (display-time-generate-time-glyphs)
|
116
|
531 (setq balloon-help
|
|
532 (format "%s, %s %s %s %s" dayname day monthname year
|
|
533 (concat " Average load:"
|
|
534 (if (not (equal load ""))
|
|
535 load
|
|
536 " 0"))))
|
|
537 (setq balloon-ext (make-extent 0 (length balloon-help) balloon-help))
|
|
538 (set-extent-property balloon-ext 'face 'red)
|
|
539 (set-extent-property balloon-ext 'duplicable 't)
|
108
|
540 (while (setq elem (pop list))
|
116
|
541 (setq elem
|
|
542 (eval (intern-soft (concat "display-time-"
|
108
|
543 (char-to-string elem)
|
116
|
544 "-glyph"))))
|
|
545 (set-extent-property (car elem) 'balloon-help balloon-help)
|
|
546 (push elem tmp))
|
|
547 (reverse tmp))))
|
108
|
548
|
110
|
549 (defun display-time-convert-load (load-string &optional textual)
|
|
550 (let ((load-number (string-to-number load-string))
|
108
|
551 (alist (list (cons 0.0 0.0)
|
|
552 (cons 0.5 (car display-time-load-list))
|
|
553 (cons 1.0 (cadr display-time-load-list))
|
|
554 (cons 1.5 (caddr display-time-load-list))
|
|
555 (cons 2.0 (cadddr display-time-load-list))
|
|
556 (cons 2.5 (cadr (cdddr display-time-load-list)))
|
|
557 (cons 3.0 (caddr (cdddr display-time-load-list)))
|
|
558 (cons 100000 100000)))
|
116
|
559 elem load-elem)
|
110
|
560 (if (not (display-time-can-do-graphical-display textual))
|
|
561 load-string
|
114
|
562 (display-time-generate-load-glyphs)
|
108
|
563 (while (>= load-number (cdr (setq elem (pop alist))))
|
116
|
564 (setq load-elem elem))
|
|
565 (eval (intern-soft (concat "display-time-load-"
|
|
566 (number-to-string (car load-elem))
|
|
567 "-glyph"))))))
|
108
|
568
|
110
|
569 (defun display-time-convert-am-pm (ampm-string &optional textual)
|
|
570 (if (not (display-time-can-do-graphical-display textual))
|
|
571 ampm-string
|
|
572 (cond ((equal ampm-string "am") display-time-am-glyph)
|
|
573 ((equal ampm-string "pm") display-time-pm-glyph))))
|
108
|
574
|
116
|
575 (defun display-time-mail-balloon (&rest ciao)
|
|
576 (let* ((mail-spool-file (or display-time-mail-file
|
|
577 (getenv "MAIL")
|
|
578 (concat rmail-spool-directory
|
|
579 (user-login-name))))
|
|
580 (show-split (and display-time-mail-balloon-show-gnus-group
|
|
581 (or (featurep 'nnmail) (require 'nnmail))))
|
|
582 (display-time-mail-balloon-gnus-split-width
|
|
583 (if (not show-split) 0
|
118
|
584 (+ 3 display-time-mail-balloon-gnus-split-width))) ; -><space>... = +3
|
116
|
585 (mod (nth 5 (file-attributes mail-spool-file)))
|
|
586 header header-ext)
|
|
587 (setq header "You have mail:")
|
|
588 (setq header-ext
|
|
589 (make-extent 0 (length header) header))
|
|
590 (set-extent-property header-ext 'face 'red)
|
|
591 (set-extent-property header-ext 'duplicable t)
|
|
592 (setq header (concat header "\n"
|
|
593 (make-string (+ display-time-mail-balloon-from-width
|
|
594 display-time-mail-balloon-subject-width
|
|
595 display-time-mail-balloon-gnus-split-width
|
|
596 3) (string-to-char "-"))))
|
|
597 (if (not (equal
|
|
598 mod display-time-spool-file-modification))
|
|
599 (progn
|
|
600 (setq display-time-spool-file-modification mod)
|
|
601 (setq display-time-mail-header
|
|
602 (display-time-scan-mail-file mail-spool-file show-split))))
|
|
603 (setq header (concat header display-time-mail-header))
|
|
604 ))
|
|
605
|
|
606
|
|
607 (defun display-time-scan-mail-file (file show-split)
|
|
608 (let ((mail-headers "")
|
|
609 (nntp-server-buffer (get-buffer-create " *Display-Time-Split-Buffer*"))
|
|
610 (suppress-count 0)
|
|
611 (not-displayed 0)
|
|
612 (i 0)
|
|
613 (suppress-list display-time-mail-balloon-suppress)
|
|
614 (enhance-list display-time-mail-balloon-enhance)
|
|
615 (gnus-suppress-list display-time-mail-balloon-suppress-gnus-group)
|
|
616 (gnus-enhance-list display-time-mail-balloon-enhance-gnus-group)
|
|
617 mail-headers-list start end from subject gnus-group tmp
|
|
618 suppress enhance line line-ext
|
|
619 gnus-suppress-reg gnus-enhance-reg suppress-reg enhance-reg)
|
|
620
|
|
621 (erase-buffer (get-buffer-create display-time-temp-buffer))
|
|
622 (message "Scanning spool file...")
|
|
623 (while (setq tmp (pop enhance-list))
|
|
624 (setq enhance-reg
|
|
625 (if (car enhance-list) (concat enhance-reg tmp "\\|")
|
|
626 (concat enhance-reg tmp))))
|
|
627 (while (setq tmp (pop suppress-list))
|
|
628 (setq suppress-reg
|
|
629 (if (car suppress-list) (concat suppress-reg tmp "\\|")
|
|
630 (concat suppress-reg tmp))))
|
|
631 (while (setq tmp (pop gnus-enhance-list))
|
|
632 (setq gnus-enhance-reg
|
|
633 (if (car gnus-enhance-list) (concat gnus-enhance-reg tmp "\\|")
|
|
634 (concat gnus-enhance-reg tmp))))
|
|
635 (while (setq tmp (pop gnus-suppress-list))
|
|
636 (setq gnus-suppress-reg
|
|
637 (if (car gnus-suppress-list) (concat gnus-suppress-reg tmp "\\|")
|
|
638 (concat gnus-suppress-reg tmp))))
|
|
639 (save-excursion
|
|
640 (set-buffer display-time-temp-buffer)
|
|
641 (setq case-fold-search nil)
|
|
642 (insert-file-contents file)
|
|
643 (goto-char (point-min))
|
|
644 (while (setq start (re-search-forward "^From " nil t))
|
|
645 (save-excursion
|
|
646 (setq end (re-search-forward "^$" nil t))
|
|
647 (narrow-to-region start end)
|
|
648 (goto-char (point-min))
|
|
649 (setq enhance
|
|
650 (save-excursion
|
|
651 (if display-time-mail-balloon-enhance
|
|
652 (re-search-forward enhance-reg nil t))))
|
|
653 (if show-split
|
|
654 (save-excursion
|
118
|
655 (goto-char (point-min))
|
116
|
656 (nnmail-article-group '(lambda (name) (setq gnus-group name)))))
|
|
657
|
|
658 (if enhance () ; this takes prejudice over everything else
|
|
659 (setq suppress ; maybe set suppress only if not already enhanced
|
|
660 (save-excursion
|
|
661 (if display-time-mail-balloon-suppress
|
|
662 (re-search-forward suppress-reg nil t))))
|
|
663 (if suppress ()
|
|
664 (or (setq enhance ;;maybe we enhance because of the gnus group name
|
|
665 (save-excursion
|
|
666 (if (and show-split gnus-group
|
|
667 display-time-mail-balloon-enhance-gnus-group)
|
|
668 (string-match gnus-enhance-reg gnus-group))))
|
118
|
669 (setq suppress ;; if we didn't enhance then maybe we have to
|
|
670 ;; suppress it?
|
116
|
671 (save-excursion
|
|
672 (if (and show-split gnus-group
|
|
673 display-time-mail-balloon-suppress-gnus-group)
|
|
674 (string-match gnus-suppress-reg gnus-group)))))))
|
|
675
|
|
676 (setq from
|
|
677 (save-excursion
|
|
678 (re-search-forward "^From: \\(.*\\)" nil t)
|
|
679 (mail-extract-address-components (match-string 1))))
|
|
680 (setq subject
|
|
681 (save-excursion
|
|
682 (re-search-forward "^Subject: \\(.*\\)" nil t)
|
|
683 (match-string 1)))
|
|
684 (if suppress (setq suppress-count (1+ suppress-count))
|
|
685 (if (car from) (setq from (car from))
|
|
686 (setq from (cadr from)))
|
|
687 (if (> (length from) display-time-mail-balloon-from-width)
|
|
688 (setq from (substring from 0
|
|
689 display-time-mail-balloon-from-width)))
|
|
690 (if (> (length subject) display-time-mail-balloon-subject-width)
|
|
691 (setq subject (substring subject 0
|
|
692 display-time-mail-balloon-subject-width)))
|
|
693 (if (and show-split gnus-group
|
|
694 (> (length gnus-group)
|
|
695 (- display-time-mail-balloon-gnus-split-width 3)))
|
|
696 (setq gnus-group (substring gnus-group 0
|
|
697 (- display-time-mail-balloon-gnus-split-width 3))))
|
|
698
|
|
699 (setq line (format (concat
|
|
700 "\n%-"(number-to-string
|
|
701 display-time-mail-balloon-from-width)
|
|
702 "s [%-"(number-to-string
|
|
703 display-time-mail-balloon-subject-width)
|
|
704 "s]")
|
|
705 from subject))
|
|
706 (if (and show-split gnus-group)
|
|
707 (setq line (concat line
|
|
708 (format
|
|
709 (concat
|
|
710 "-> %" (number-to-string
|
|
711 (- display-time-mail-balloon-gnus-split-width 3))
|
|
712 "s") gnus-group))))
|
|
713 (if enhance
|
|
714 (progn
|
|
715 (setq line-ext (make-extent 1 (length line) line))
|
|
716 (set-extent-property line-ext 'face
|
|
717 'display-time-mail-balloon-enhance-face)
|
|
718 (set-extent-property line-ext 'duplicable t)
|
|
719 (set-extent-property line-ext 'end-open t)))
|
|
720 (if (and show-split gnus-group)
|
|
721 (progn
|
|
722 (setq line-ext (make-extent (- (length line)
|
|
723 display-time-mail-balloon-gnus-split-width)
|
|
724 (length line) line))
|
|
725 (set-extent-property line-ext 'face
|
|
726 'display-time-mail-balloon-gnus-group-face)
|
|
727 (set-extent-property line-ext 'duplicable t)
|
|
728 (set-extent-property line-ext 'end-open t)))
|
|
729 (push line mail-headers-list))
|
118
|
730 (goto-char (point-max))
|
116
|
731 (setq suppress nil
|
|
732 gnus-group nil
|
|
733 enhance nil)
|
|
734 (widen)
|
|
735 )))
|
118
|
736 (kill-buffer display-time-temp-buffer)
|
116
|
737 (if (> (length mail-headers-list) display-time-mail-balloon-max-displayed)
|
|
738 (setq not-displayed (- (length mail-headers-list)
|
|
739 display-time-mail-balloon-max-displayed)))
|
|
740 (while (< i display-time-mail-balloon-max-displayed)
|
|
741 (setq mail-headers (concat mail-headers (pop mail-headers-list)))
|
|
742 (setq i (1+ i)))
|
|
743 (if (and (equal mail-headers "") (> suppress-count 0))
|
|
744 (setq mail-headers "\nOnly junk mail..."))
|
|
745 (concat mail-headers "\n"
|
|
746 (make-string (+ display-time-mail-balloon-from-width
|
|
747 display-time-mail-balloon-subject-width
|
|
748 display-time-mail-balloon-gnus-split-width
|
|
749 3) (string-to-char "-"))
|
|
750 "\n"
|
|
751 (if (> not-displayed 0)
|
|
752 (concat "More: " (number-to-string not-displayed)"\n"))
|
|
753 (if (> suppress-count 0)
|
|
754 (concat "Suppressed: " (number-to-string suppress-count)))
|
|
755 )))
|
|
756
|
108
|
757
|
110
|
758 (defun display-time-mail-sign (&optional textual)
|
108
|
759 "*A function giving back the object indicating 'mail' which
|
|
760 is the value of display-time-mail-sign when running under X,
|
|
761 display-time-echo-area is nil and display-time-show-icons-maybe is t.
|
116
|
762 It is the value of display-time-mail-sign-string otherwise or when
|
|
763 the optional parameter TEXTUAL is non-nil."
|
110
|
764 (if (not (display-time-can-do-graphical-display textual))
|
108
|
765 display-time-mail-sign-string
|
116
|
766 (list " " display-time-mail-sign " ")))
|
108
|
767
|
110
|
768 (defun display-time-no-mail-sign (&optional textual)
|
108
|
769 "*A function giving back the object indicating 'no mail' which
|
|
770 is the value of display-time-no-mail-sign when running under X,
|
|
771 display-time-echo-area is nil and display-time-show-icons-maybe is t.
|
116
|
772 It is the value of display-time-no-mail-sign-string otherwise or when
|
|
773 the optional parameter TEXTUAL is non-nil."
|
110
|
774 (if (not (display-time-can-do-graphical-display textual))
|
108
|
775 display-time-no-mail-sign-string
|
116
|
776 (list " " display-time-no-mail-sign " ")))
|
108
|
777
|
110
|
778 (defcustom display-time-form-list
|
|
779 (list 'date 'time 'load 'mail)
|
|
780 "*This list describes the format of the strings/glyphs
|
|
781 which are to be displayed by display-time.
|
|
782 The old variable display-time-string-forms is only used if
|
|
783 display-time-compatible is non-nil. It is a list consisting of
|
108
|
784 strings or any of the following symbols:
|
|
785
|
110
|
786 There are three complex specs whose behaviour is changed via
|
|
787 the setting of various variables
|
108
|
788
|
110
|
789 date: This prints out the date in a manner compatible to
|
|
790 the default value of the obsolete variable
|
|
791 display-time-string-forms. It respects the variable
|
|
792 display-time-day-and-date. If this is t it will print
|
|
793 out the current date in the form DAYNAME MONTH DAY
|
|
794 otherwise it will print nothing.
|
|
795
|
|
796 time: This prints out the time in a manner compatible to
|
|
797 the default value of the obsolete variable
|
|
798 display-time-string-forms. It respects the variable
|
|
799 display-time-24hr-format. If this is t it will print
|
|
800 out the current hours in 24-hour format, if nil the
|
|
801 hours will be printed in 12-hour format and the
|
|
802 minutes will be followed by 'AM' or 'PM'.
|
|
803
|
|
804 time-text: The same as above, but will not use a glyph
|
|
805
|
|
806 The other specs are simpler, as their meaning is not changed via
|
|
807 variables.
|
108
|
808
|
110
|
809 24-hours: This prints the hours in 24-hours format
|
|
810
|
|
811 24-hours-text: The same as above, but will not use a glyph
|
|
812
|
|
813 12-hours: This prints the hours in 12-hours format
|
|
814
|
|
815 12-hours-text: The same as above, but will not use a glyph
|
|
816
|
|
817 am-pm: This prints am or pm.
|
108
|
818
|
110
|
819 Timezone: This prints out the local timezone
|
|
820
|
|
821 am-pm-text: The same as above, but will not use a glyph
|
|
822
|
|
823 minutes: This prints the minutes.
|
|
824
|
|
825 minutes-text: The same as above, but will not use a glyph
|
|
826
|
|
827 day: This prints out the current day as a number.
|
|
828
|
|
829 dayname: This prints out today's name.
|
|
830
|
|
831 month: This prints out the current month as a number
|
|
832
|
|
833 monthname: This prints out the current month's name
|
108
|
834
|
110
|
835 year: This prints out the current year.
|
|
836
|
|
837 load: This prints out the system's load.
|
|
838
|
|
839 load-text: The same as above, but will not use a glyph
|
|
840
|
|
841 mail: This displays a mail indicator. Under X this will
|
|
842 normally be a small icon which changes depending if
|
|
843 there is new mail or not.
|
|
844
|
|
845 mail-text: The same as above, but will not use a glyph"
|
|
846 :group 'display-time
|
114
|
847 :type '(repeat (choice :tag "Symbol/String"
|
110
|
848 (const :tag "Date" date)
|
|
849 (const :tag "Time" time)
|
|
850 (const :tag "Time (text)" time-text)
|
|
851 (const :tag "24 hour format" 24-hours)
|
|
852 (const :tag "24 hour format (text)" 24-hours-text)
|
|
853 (const :tag "12 hour format" 12-hours)
|
|
854 (const :tag "12 hour format (text)" 12-hours-text)
|
|
855 (const :tag "AM/PM indicator" am-pm)
|
|
856 (const :tag "AM/PM indicator (text)" am-pm-text)
|
|
857 (const :tag "Timezone" timezone)
|
|
858 (const :tag "Minutes" minutes)
|
|
859 (const :tag "Minutes (text)" minutes-text)
|
|
860 (const :tag "Day" day)
|
|
861 (const :tag "Dayname" dayname)
|
|
862 (const :tag "Month" month)
|
|
863 (const :tag "Monthname" monthname)
|
|
864 (const :tag "Year" year)
|
|
865 (const :tag "Load" load)
|
|
866 (const :tag "Load (text)" load-text)
|
|
867 (const :tag "Mail sign" mail)
|
|
868 (const :tag "Mail sign (text)" mail-text)
|
|
869 (string :tag "String"))))
|
108
|
870
|
|
871 (defun display-time-evaluate-list ()
|
|
872 "Evalute the variable display-time-form-list"
|
|
873 (let ((list display-time-form-list) elem tmp result)
|
|
874 (while (setq elem (pop list))
|
|
875 (cond ((stringp elem) (push elem tmp))
|
110
|
876 ((eq elem 'date)
|
108
|
877 (push (if display-time-day-and-date
|
|
878 (format "%s %s %s " dayname monthname day) "") tmp))
|
110
|
879 ((eq elem 'time)
|
108
|
880 (progn
|
110
|
881 (push (display-time-convert-num
|
108
|
882 (format "%s:%s"
|
|
883 (if display-time-24hr-format 24-hours 12-hours)
|
110
|
884 minutes)) tmp)
|
108
|
885 (if (not display-time-24hr-format)
|
|
886 (push (display-time-convert-am-pm am-pm) tmp))))
|
110
|
887 ((eq elem 'time-text)
|
|
888 (push (display-time-convert-num
|
|
889 (format "%s:%s"
|
|
890 (if display-time-24hr-format 24-hours 12-hours)
|
|
891 minutes) t) tmp)
|
|
892 (if (not display-time-24hr-format)
|
|
893 (push (display-time-convert-am-pm am-pm t) tmp)))
|
108
|
894 ((eq elem 'day) (push day tmp))
|
|
895 ((eq elem 'dayname) (push dayname tmp))
|
|
896 ((eq elem 'month) (push month tmp))
|
|
897 ((eq elem 'monthname) (push monthname tmp))
|
110
|
898 ((eq elem '24-hours)
|
|
899 (push (display-time-convert-num 24-hours) tmp))
|
|
900 ((eq elem 'year)
|
|
901 (push year tmp))
|
|
902 ((eq elem '24-hours-text)
|
|
903 (push (display-time-convert-num 24-hours t) tmp))
|
|
904 ((eq elem '12-hours)
|
|
905 (push (display-time-convert-num 12-hours) tmp))
|
|
906 ((eq elem '12-hours-text)
|
|
907 (push (display-time-convert-num 12-hours t) tmp))
|
|
908 ((eq elem 'minutes)
|
|
909 (push (display-time-convert-num minutes) tmp))
|
|
910 ((eq elem 'minutes-text)
|
|
911 (push (display-time-convert-num minutes t) tmp))
|
|
912 ((eq elem 'am-pm)
|
|
913 (push (display-time-convert-am-pm am-pm) tmp))
|
|
914 ((eq elem 'am-pm-text)
|
|
915 (push (display-time-convert-am-pm am-pm t) tmp))
|
|
916 ((eq elem 'timezone)
|
|
917 (push time-zone tmp))
|
108
|
918 ((eq elem 'load)
|
110
|
919 (push (display-time-convert-load load) tmp))
|
|
920 ((eq elem 'load-text)
|
|
921 (push (display-time-convert-load load t) tmp))
|
|
922 ((eq elem 'mail)
|
|
923 (push (if mail (display-time-mail-sign)
|
|
924 (display-time-no-mail-sign)) tmp))
|
|
925 ((eq elem 'mail-text)
|
|
926 (push (if mail (display-time-mail-sign t)
|
|
927 (display-time-no-mail-sign t)) tmp))
|
|
928 ))
|
108
|
929 ;; We know that we have a list containing only of strings if
|
|
930 ;; display-time-echo-area is t. So we construct this string from
|
|
931 ;; the list. Else we just reverse the list and give it as result.
|
|
932 (if (not display-time-echo-area) (setq result (reverse tmp))
|
|
933 (while (setq elem (pop tmp))
|
|
934 (setq result (concat elem result))))
|
|
935 result))
|
|
936
|
|
937
|
0
|
938 (defvar display-time-string-forms
|
|
939 '((if display-time-day-and-date
|
|
940 (format "%s %s %s " dayname monthname day)
|
|
941 "")
|
|
942 (format "%s:%s%s"
|
|
943 (if display-time-24hr-format 24-hours 12-hours)
|
|
944 minutes
|
|
945 (if display-time-24hr-format "" am-pm))
|
108
|
946 load
|
|
947 (if mail " Mail" ""))
|
118
|
948 "*It will only be used if display-time-compatible is t.
|
108
|
949 A list of expressions governing display of the time in the mode line.
|
0
|
950 This expression is a list of expressions that can involve the keywords
|
|
951 `load', `day', `month', and `year', `12-hours', `24-hours', `minutes',
|
|
952 `seconds', all numbers in string form, and `monthname', `dayname', `am-pm',
|
104
|
953 and `time-zone' all alphabetic strings and `mail' a true/nil string value.
|
0
|
954
|
|
955 For example, the form
|
|
956
|
|
957 '((substring year -2) \"/\" month \"/\" day
|
|
958 \" \" 24-hours \":\" minutes \":\" seconds
|
104
|
959 (if time-zone \" (\") time-zone (if time-zone \")\"))
|
0
|
960
|
|
961 would give mode line times like `94/12/30 21:07:48 (UTC)'.")
|
|
962
|
118
|
963 (make-obsolete-variable 'display-time-string-forms
|
|
964 "You should use the new facilities for `display-time'.
|
|
965 Look at display-time-form-list.")
|
|
966
|
0
|
967 (defun display-time-function ()
|
|
968 (let* ((now (current-time))
|
|
969 (time (current-time-string now))
|
|
970 (load (condition-case ()
|
|
971 (if (zerop (car (load-average))) ""
|
|
972 (let ((str (format " %03d" (car (load-average)))))
|
|
973 (concat (substring str 0 -2) "." (substring str -2))))
|
|
974 (error "")))
|
|
975 (mail-spool-file (or display-time-mail-file
|
|
976 (getenv "MAIL")
|
|
977 (concat rmail-spool-directory
|
|
978 (user-login-name))))
|
|
979 (mail (and (stringp mail-spool-file)
|
|
980 (or (null display-time-server-down-time)
|
|
981 ;; If have been down for 20 min, try again.
|
|
982 (> (- (nth 1 (current-time))
|
|
983 display-time-server-down-time)
|
|
984 1200))
|
|
985 (let ((start-time (current-time)))
|
|
986 (prog1
|
|
987 (display-time-file-nonempty-p mail-spool-file)
|
|
988 (if (> (- (nth 1 (current-time)) (nth 1 start-time))
|
|
989 20)
|
|
990 ;; Record that mail file is not accessible.
|
|
991 (setq display-time-server-down-time
|
|
992 (nth 1 (current-time)))
|
|
993 ;; Record that mail file is accessible.
|
|
994 (setq display-time-server-down-time nil))))))
|
|
995 (24-hours (substring time 11 13))
|
|
996 (hour (string-to-int 24-hours))
|
|
997 (12-hours (int-to-string (1+ (% (+ hour 11) 12))))
|
|
998 (am-pm (if (>= hour 12) "pm" "am"))
|
|
999 (minutes (substring time 14 16))
|
|
1000 (seconds (substring time 17 19))
|
|
1001 (time-zone (car (cdr (current-time-zone now))))
|
|
1002 (day (substring time 8 10))
|
|
1003 (year (substring time 20 24))
|
|
1004 (monthname (substring time 4 7))
|
|
1005 (month
|
|
1006 (cdr
|
|
1007 (assoc
|
|
1008 monthname
|
|
1009 '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4")
|
|
1010 ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8")
|
|
1011 ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12")))))
|
|
1012 (dayname (substring time 0 3)))
|
|
1013 (setq display-time-string
|
108
|
1014 (if display-time-compatible
|
|
1015 (mapconcat 'eval display-time-string-forms "")
|
|
1016 (display-time-evaluate-list)))
|
0
|
1017 ;; This is inside the let binding, but we are not going to document
|
|
1018 ;; what variables are available.
|
|
1019 (run-hooks 'display-time-hook))
|
|
1020 (if display-time-echo-area
|
|
1021 (or (> (minibuffer-depth) 0)
|
|
1022 ;; don't stomp echo-area-buffer if reading from minibuffer now.
|
|
1023 (save-excursion
|
|
1024 (save-window-excursion
|
|
1025 (select-window (minibuffer-window))
|
|
1026 (erase-buffer)
|
110
|
1027 (indent-to (- (frame-width) (length display-time-string) 1))
|
0
|
1028 (insert display-time-string)
|
|
1029 (message (buffer-string)))))
|
|
1030 (force-mode-line-update)
|
|
1031 ;; Do redisplay right now, if no input pending.
|
|
1032 (sit-for 0)))
|
|
1033
|
|
1034 (defun display-time-file-nonempty-p (file)
|
110
|
1035 (let ((attributes (file-attributes (file-chase-links file))))
|
|
1036 (and attributes
|
|
1037 (< 0 (nth 7 attributes))
|
|
1038 (or display-time-ignore-read-mail
|
|
1039 (> (car (nth 5 attributes)) (car (nth 4 attributes)))
|
|
1040 (and (= (car (nth 5 attributes)) (car (nth 4 attributes)))
|
|
1041 (> (cadr (nth 5 attributes)) (cadr (nth 4 attributes))))))))
|
0
|
1042
|
|
1043 (provide 'time)
|
|
1044
|
|
1045 ;;; time.el ends here
|