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