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