annotate lisp/packages/time.el @ 104:cf808b4c4290 r20-1b4

Import from CVS: tag r20-1b4
author cvs
date Mon, 13 Aug 2007 09:16:51 +0200
parents 131b0175ea99
children 360340f9fd5f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; time.el --- display time and load in mode line of Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3 ;; Copyright (C) 1985, 86, 87, 93, 94, 1996 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
5 ;; Maintainer: FSF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
22 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
24 ;;; Synched up with: Not synched with FSF.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
28 ;; Facilities to display current time/date and a new-mail indicator
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
29 ;; in the Emacs mode line. The single entry point is `display-time'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
31 ;; See also reportmail.el.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
32 ;; This uses the XEmacs timeout-event mechanism, via a version
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
33 ;; of Kyle Jones' itimer package.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (require 'itimer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
39 (defvar display-time-mail-file nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 "*File name of mail inbox file, for indicating existence of new mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 Non-nil and not a string means don't check for mail. nil means use
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
42 default, which is system-dependent, and is the same as used by Rmail.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;###autoload
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
45 (defvar display-time-day-and-date nil "\
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
46 *Non-nil means \\[display-time] should display day and date as well as time.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
48 (defvar display-time-interval 60
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
49 "*Seconds between updates of time in the mode line.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
51 (defvar display-time-24hr-format nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
53 Nil means 1 <= hh <= 12, and an AM/PM suffix is used.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
55 (defvar display-time-echo-area nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
56 "*If non-nil, display-time will use the echo area instead of the mode line.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defvar display-time-string nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
60 (defvar display-time-hook nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
61 "*List of functions to be called when the time is updated on the mode line.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defvar display-time-server-down-time nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "Time when mail file's file system was recorded to be down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 If that file system seems to be up, the value is nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defun display-time ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "Display current time, load level, and mail flag in mode line of each buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 Updates automatically every minute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 If `display-time-day-and-date' is non-nil, the current day and date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 are displayed as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 After each update, `display-time-hook' is run with `run-hooks'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 If `display-time-echo-area' is non-nil, the time is displayed in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 echo area instead of in the mode-line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; if the "display-time" itimer already exists, nuke it first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (let ((old (get-itimer "display-time")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (if old (delete-itimer old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; If we're not displaying the time in the echo area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; and the global mode string does not have a non-nil value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; then initialize the global mode string's value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (or display-time-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 global-mode-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq global-mode-string '("")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; If we're not displaying the time in the echo area
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
87 ;; and our display variable is not part of the global-mode-string list
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
88 ;; the we add our variable to the list. This will make the time
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; appear on the modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (or display-time-echo-area
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
91 (memq 'display-time-string global-mode-string)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (setq global-mode-string
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
93 (append global-mode-string '(display-time-string))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; Display the time initially...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (display-time-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; ... and start an itimer to do it automatically thereafter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; If we wanted to be really clever about this, we could have the itimer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; not be automatically restarted, but have it re-add itself each time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; Then we could look at (current-time) and arrange for the itimer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; wake up exactly at the minute boundary. But that's just a little
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; more work than it's worth...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (start-itimer "display-time" 'display-time-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 display-time-interval display-time-interval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
106 (defvar display-time-show-load t)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
107
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
108 (defvar display-time-show-icons-maybe t
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
109 "Use icons to indicate the mail status if we're running under X and
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
110 XEmacs was compiled with xpm support")
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
111
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
112 (defun display-time-get-icons-dir ()
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
113 (let ((path load-path)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
114 dir elem)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
115 (while (setq elem (pop path))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
116 (setq dir (concat (directory-file-name elem) "/../etc/time/"))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
117 (if (file-directory-p dir) (setq path nil)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
118 nil))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
119 dir))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
120
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
121 (defvar display-time-icons-dir (display-time-get-icons-dir))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
122
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
123 (defvar display-time-mail-sign
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
124 (progn
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
125 (let* ((file (concat display-time-icons-dir "letter.xpm"))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
126 (glyph (if (featurep 'xpm) (make-glyph file) nil))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
127 (display-time-mail-ext (detach-extent (make-extent 1 1))))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
128 (if (and (featurep 'x) glyph
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
129 (file-exists-p file))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
130 (cons display-time-mail-ext glyph)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
131 " Mail")))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
132 "A variable holding a string or a cons cell (ext . glyph) which gives
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
133 an indicator for unread mail. The default displays a xpm-file (a yellow letter)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
134 if (feturep 'xpm) and (featurep 'x) are both t, a string \" Mail\" otherwise")
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
135
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
136 (defvar display-time-no-mail-sign
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
137 (progn
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
138 (let* ((file (concat display-time-icons-dir "no-letter.xpm"))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
139 (glyph (if (featurep 'xpm) (make-glyph file) nil))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
140 (display-time-mail-ext (detach-extent (make-extent 1 1))))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
141 (if (and (featurep 'x) glyph
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
142 (file-exists-p file))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
143 (cons display-time-mail-ext glyph)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
144 "")))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
145 "A variable holding a string or a cons cell (ext . glyph) which gives
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
146 an indicator for `no mail'. The default displays a xpm-file
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
147 if (feturep 'xpm) and (featurep 'x) are both t, and nothing otherwise")
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
148
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
149
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defvar display-time-string-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 '((if display-time-day-and-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (format "%s %s %s " dayname monthname day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (format "%s:%s%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if display-time-24hr-format 24-hours 12-hours)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 minutes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (if display-time-24hr-format "" am-pm))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
158 (if display-time-show-load load)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
159 (if (and (not display-time-show-icons-maybe) mail) " Mail" ""))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
160 "*A list of expressions governing display of the time in the mode line.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 This expression is a list of expressions that can involve the keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 `load', `day', `month', and `year', `12-hours', `24-hours', `minutes',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 `seconds', all numbers in string form, and `monthname', `dayname', `am-pm',
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
164 and `time-zone' all alphabetic strings and `mail' a true/nil string value.
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
165 Beware: if display-time-show-icons-maybe is non-nil, the `mail' spec is also
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
166 evaluated after this form and depending on it's result display-time-mail-sign
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
167 or display-time-no-mail-sign is appended to the modeline string.
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
168 This was made so you can also use xpm-files as mail indicator.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 For example, the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 '((substring year -2) \"/\" month \"/\" day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 \" \" 24-hours \":\" minutes \":\" seconds
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
174 (if time-zone \" (\") time-zone (if time-zone \")\"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 would give mode line times like `94/12/30 21:07:48 (UTC)'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defun display-time-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (let* ((now (current-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (time (current-time-string now))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (load (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (if (zerop (car (load-average))) ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (let ((str (format " %03d" (car (load-average)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (concat (substring str 0 -2) "." (substring str -2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (error "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (mail-spool-file (or display-time-mail-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (getenv "MAIL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (concat rmail-spool-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (mail (and (stringp mail-spool-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (or (null display-time-server-down-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; If have been down for 20 min, try again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (> (- (nth 1 (current-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 display-time-server-down-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 1200))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (let ((start-time (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (display-time-file-nonempty-p mail-spool-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if (> (- (nth 1 (current-time)) (nth 1 start-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; Record that mail file is not accessible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq display-time-server-down-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (nth 1 (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; Record that mail file is accessible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (setq display-time-server-down-time nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (24-hours (substring time 11 13))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (hour (string-to-int 24-hours))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (12-hours (int-to-string (1+ (% (+ hour 11) 12))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (am-pm (if (>= hour 12) "pm" "am"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (minutes (substring time 14 16))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (seconds (substring time 17 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (time-zone (car (cdr (current-time-zone now))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (day (substring time 8 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (year (substring time 20 24))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (monthname (substring time 4 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 monthname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (dayname (substring time 0 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (setq display-time-string
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
225 (mapconcat 'eval display-time-string-forms ""))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
226 (if (and mail display-time-show-icons-maybe)
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
227 (setq display-time-string
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
228 (list display-time-string display-time-mail-sign))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
229 (if display-time-show-icons-maybe
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
230 (setq display-time-string
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
231 (list display-time-string display-time-no-mail-sign))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;; This is inside the let binding, but we are not going to document
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;; what variables are available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (run-hooks 'display-time-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (if display-time-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (or (> (minibuffer-depth) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; don't stomp echo-area-buffer if reading from minibuffer now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (select-window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (erase-buffer)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
242 (indent-to (- (screen-width) (length display-time-string) 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (insert display-time-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (message (buffer-string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (force-mode-line-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; Do redisplay right now, if no input pending.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (sit-for 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun display-time-file-nonempty-p (file)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
250 (and (file-exists-p file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
251 (< 0 (nth 7 (file-attributes (file-chase-links file))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (provide 'time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;; time.el ends here