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