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