annotate lisp/packages/time.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents 360340f9fd5f
children 8619ce7e4c50
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
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
5 ;; Maintainer: FSF, XEmacs add-ons (C) by Jens T. Lautenbacher
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
6 ;; mail <jens@lemming0.lem.uni-karlsruhe.de>
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
7 ;; for comments/fixes about the enhancements.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; 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
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
24 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
26 ;;; Synched up with: Not synched with FSF.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
30 ;; Facilities to display current time/date and a new-mail indicator
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
31 ;; in the Emacs mode line. The single entry point is `display-time'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
33 ;; See also reportmail.el.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
34 ;; This uses the XEmacs timeout-event mechanism, via a version
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
35 ;; of Kyle Jones' itimer package.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
37 ;;; JTL: This is in a wide part reworked for XEmacs so it won't use
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
38 ;;; the old mechanism for specifying what is to be displayed.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
39 ;;; The starting variable to look at is `display-time-form-list'
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
40
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (require 'itimer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
45 (defgroup display-time nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
46 "Facilities to display the current time/date/load and a new-mail indicator
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
47 in the XEmacs mode line or echo area."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
48 :group 'applications)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
49
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
50 (defcustom display-time-compatible nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
51 "*This variable may be set to t to get the old behaviour of display-time.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
52 This means no display of a spiffy mail icon or use of the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
53 display-time-form-list instead of the old display-time-string-form."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
54 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
55 :type 'boolean)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
56
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
57 (defcustom display-time-mail-file nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 "*File name of mail inbox file, for indicating existence of new mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Non-nil and not a string means don't check for mail. nil means use
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
60 default, which is system-dependent, and is the same as used by Rmail."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
61 :group 'display-time)
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 ;;;###autoload
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
64 (defcustom display-time-day-and-date nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
65 "*Non-nil means \\[display-time] should display day,date and time.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
66 This affects the spec 'date in the variable display-time-form-list."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
67 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
68 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
70 (defcustom display-time-interval 20
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
71 "*Seconds between updates of time in the mode line."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
72 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
73 :type 'integer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
75 (defcustom display-time-24hr-format nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23.
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
77 Nil means 1 <= hh <= 12, and an AM/PM suffix is used.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
78 This affects the spec 'time in the variable display-time-form-list."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
79 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
80 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
82 (defcustom display-time-echo-area nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
83 "*If non-nil, display-time will use the echo area instead of the mode line."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
84 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
85 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defvar display-time-string nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
89 (defcustom display-time-hook nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
90 "*List of functions to be called when the time is updated on the mode line."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
91 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
92 :type 'hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (defvar display-time-server-down-time nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 "Time when mail file's file system was recorded to be down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 If that file system seems to be up, the value is nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
98 (defcustom display-time-ignore-read-mail nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
99 "*Non-nil means displays the mail icon on any non-empty mailbox."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
100 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
101 :type 'boolean)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
102
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defun display-time ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "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
106 Updates automatically every minute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 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
108 are displayed as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 After each update, `display-time-hook' is run with `run-hooks'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 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
111 echo area instead of in the mode-line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; if the "display-time" itimer already exists, nuke it first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (let ((old (get-itimer "display-time")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if old (delete-itimer old)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
116
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
117 (if (memq 'display-time-string global-mode-string)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
118 (setq global-mode-string
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
119 (remove 'display-time-string global-mode-string)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; If we're not displaying the time in the echo area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; and the global mode string does not have a non-nil value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; then initialize the global mode string's value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (or display-time-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 global-mode-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq global-mode-string '("")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; If we're not displaying the time in the echo area
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
127 ;; then we add our variable to the list. This will make the time
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; appear on the modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (or display-time-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (setq global-mode-string
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
131 (append global-mode-string '(display-time-string))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; Display the time initially...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (display-time-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; ... and start an itimer to do it automatically thereafter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; 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
137 ;; not be automatically restarted, but have it re-add itself each time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; Then we could look at (current-time) and arrange for the itimer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; wake up exactly at the minute boundary. But that's just a little
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; more work than it's worth...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (start-itimer "display-time" 'display-time-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 display-time-interval display-time-interval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
144 (defcustom display-time-show-icons-maybe t
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
145 "Use icons for time, load and mail status if possible
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
146 and not specified different explicitely"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
147 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
148 :type 'boolean)
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
149
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
150 (defvar display-time-icons-dir (concat data-directory "time/"))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
151
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
152 (defcustom display-time-mail-sign-string " Mail"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
153 "The string used as mail indicator in the echo area
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
154 (and in the modeline if display-time-show-icons-maybe is nil)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
155 if display-time-echo-area is t"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
156 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
157 :type 'string)
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
158
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
159 (defcustom display-time-no-mail-sign-string ""
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
160 "The string used as no-mail indicator in the echo area
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
161 (and in the modeline if display-time-show-icons-maybe is nil)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
162 if display-time-echo-area is t"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
163 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
164 :type 'string)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
165
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
166 (defcustom display-time-display-pad t
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
167 "Wether the load indicator is displayed with a trapezoidal \"pad\"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
168 in the background"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
169 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
170 :type 'boolean)
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
171
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
172 (defcustom display-time-load-list
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
173 (list 0.2 0.5 0.8 1.1 1.8 2.6)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
174 "*A list giving six thresholds for the load
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
175 which correspond to the six different icons to be displayed
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
176 as a load indicator"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
177 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
178 :type '(list (number :tag "Threshold 1 load")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
179 (number :tag "Threshold 2 load")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
180 (number :tag "Threshold 3 load")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
181 (number :tag "Threshold 4 load")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
182 (number :tag "Threshold 5 load")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
183 (number :tag "Threshold 6 load")))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
184
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
185 (defun display-time-string-to-char-list (str)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
186 (mapcar (function identity) str))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
187
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
188 (if (featurep 'xpm)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
189 (progn
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
190 (defvar display-time-mail-sign
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
191 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
192 (make-glyph (concat display-time-icons-dir "letter.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
193 (defvar display-time-no-mail-sign
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
194 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
195 (make-glyph (concat display-time-icons-dir "no-letter.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
196 (defvar display-time-1-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
197 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
198 (make-glyph (concat display-time-icons-dir "1.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
199 (defvar display-time-2-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
200 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
201 (make-glyph (concat display-time-icons-dir "2.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
202 (defvar display-time-3-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
203 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
204 (make-glyph (concat display-time-icons-dir "3.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
205 (defvar display-time-4-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
206 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
207 (make-glyph (concat display-time-icons-dir "4.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
208 (defvar display-time-5-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
209 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
210 (make-glyph (concat display-time-icons-dir "5.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
211 (defvar display-time-6-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
212 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
213 (make-glyph (concat display-time-icons-dir "6.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
214 (defvar display-time-7-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
215 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
216 (make-glyph (concat display-time-icons-dir "7.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
217 (defvar display-time-8-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
218 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
219 (make-glyph (concat display-time-icons-dir "8.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
220 (defvar display-time-9-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
221 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
222 (make-glyph (concat display-time-icons-dir "9.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
223 (defvar display-time-0-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
224 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
225 (make-glyph (concat display-time-icons-dir "0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
226 (defvar display-time-:-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
227 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
228 (make-glyph (concat display-time-icons-dir "dp.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
229 (defvar display-time-load-0.0-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
230 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
231 (make-glyph (concat display-time-icons-dir "l-0.0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
232 (defvar display-time-load-0.5-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
233 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
234 (make-glyph (concat display-time-icons-dir "l-0.5.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
235 (defvar display-time-load-1.0-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
236 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
237 (make-glyph (concat display-time-icons-dir "l-1.0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
238 (defvar display-time-load-1.5-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
239 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
240 (make-glyph (concat display-time-icons-dir "l-1.5.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
241 (defvar display-time-load-2.0-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
242 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
243 (make-glyph (concat display-time-icons-dir "l-2.0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
244 (defvar display-time-load-2.5-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
245 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
246 (make-glyph (concat display-time-icons-dir "l-2.5.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
247 (defvar display-time-load-3.0-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
248 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
249 (make-glyph (concat display-time-icons-dir "l-3.0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
250 (defvar display-time-load-0.0-jtl-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
251 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
252 (make-glyph (concat display-time-icons-dir "l-jtl-0.0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
253 (defvar display-time-load-0.5-jtl-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
254 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
255 (make-glyph (concat display-time-icons-dir "l-jtl-0.5.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
256 (defvar display-time-load-1.0-jtl-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
257 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
258 (make-glyph (concat display-time-icons-dir "l-jtl-1.0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
259 (defvar display-time-load-1.5-jtl-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
260 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
261 (make-glyph (concat display-time-icons-dir "l-jtl-1.5.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
262 (defvar display-time-load-2.0-jtl-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
263 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
264 (make-glyph (concat display-time-icons-dir "l-jtl-2.0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
265 (defvar display-time-load-2.5-jtl-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
266 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
267 (make-glyph (concat display-time-icons-dir "l-jtl-2.5.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
268 (defvar display-time-load-3.0-jtl-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
269 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
270 (make-glyph (concat display-time-icons-dir "l-jtl-3.0.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
271 (defvar display-time-am-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
272 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
273 (make-glyph (concat display-time-icons-dir "am.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
274 (defvar display-time-pm-glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
275 (cons (make-extent nil nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
276 (make-glyph (concat display-time-icons-dir "pm.xpm"))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
277 ))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
278
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
279
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
280 (defun display-time-can-do-graphical-display (&optional textual)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
281 (and display-time-show-icons-maybe
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
282 (not textual)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
283 (eq (console-type) 'x)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
284 (featurep 'xpm)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
285 (not display-time-echo-area)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
286
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
287
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
288 (defun display-time-convert-num (time-string &optional textual)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
289 (let ((list (display-time-string-to-char-list time-string))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
290 elem tmp)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
291 (if (not (display-time-can-do-graphical-display textual)) time-string
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
292 (while (setq elem (pop list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
293 (push (eval (intern-soft (concat "display-time-"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
294 (char-to-string elem)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
295 "-glyph"))) tmp))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
296 (reverse tmp))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
297
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
298 (defun display-time-convert-load (load-string &optional textual)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
299 (let ((load-number (string-to-number load-string))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
300 (alist (list (cons 0.0 0.0)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
301 (cons 0.5 (car display-time-load-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
302 (cons 1.0 (cadr display-time-load-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
303 (cons 1.5 (caddr display-time-load-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
304 (cons 2.0 (cadddr display-time-load-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
305 (cons 2.5 (cadr (cdddr display-time-load-list)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
306 (cons 3.0 (caddr (cdddr display-time-load-list)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
307 (cons 100000 100000)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
308 result elem)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
309 (if (not (display-time-can-do-graphical-display textual))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
310 load-string
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
311 (while (>= load-number (cdr (setq elem (pop alist))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
312 (setq result (eval (intern-soft (concat
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
313 "display-time-load-"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
314 (number-to-string (car elem))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
315 (if display-time-display-pad "-jtl")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
316 "-glyph")))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
317 result)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
318
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
319 (defun display-time-convert-am-pm (ampm-string &optional textual)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
320 (if (not (display-time-can-do-graphical-display textual))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
321 ampm-string
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
322 (cond ((equal ampm-string "am") display-time-am-glyph)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
323 ((equal ampm-string "pm") display-time-pm-glyph))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
324
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
325
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
326 (defun display-time-mail-sign (&optional textual)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
327 "*A function giving back the object indicating 'mail' which
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
328 is the value of display-time-mail-sign when running under X,
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
329 display-time-echo-area is nil and display-time-show-icons-maybe is t.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
330 It is the value of display-time-mail-sign-string otherwise."
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
331 (if (not (display-time-can-do-graphical-display textual))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
332 display-time-mail-sign-string
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
333 display-time-mail-sign))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
334
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
335 (defun display-time-no-mail-sign (&optional textual)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
336 "*A function giving back the object indicating 'no mail' which
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
337 is the value of display-time-no-mail-sign when running under X,
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
338 display-time-echo-area is nil and display-time-show-icons-maybe is t.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
339 It is the value of display-time-no-mail-sign-string otherwise."
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
340 (if (not (display-time-can-do-graphical-display textual))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
341 display-time-no-mail-sign-string
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
342 display-time-no-mail-sign))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
343
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
344 (defcustom display-time-form-list
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
345 (list 'date 'time 'load 'mail)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
346 "*This list describes the format of the strings/glyphs
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
347 which are to be displayed by display-time.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
348 The old variable display-time-string-forms is only used if
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
349 display-time-compatible is non-nil. It is a list consisting of
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
350 strings or any of the following symbols:
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
351
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
352 There are three complex specs whose behaviour is changed via
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
353 the setting of various variables
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
354
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
355 date: This prints out the date in a manner compatible to
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
356 the default value of the obsolete variable
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
357 display-time-string-forms. It respects the variable
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
358 display-time-day-and-date. If this is t it will print
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
359 out the current date in the form DAYNAME MONTH DAY
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
360 otherwise it will print nothing.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
361
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
362 time: This prints out the time in a manner compatible to
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
363 the default value of the obsolete variable
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
364 display-time-string-forms. It respects the variable
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
365 display-time-24hr-format. If this is t it will print
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
366 out the current hours in 24-hour format, if nil the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
367 hours will be printed in 12-hour format and the
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
368 minutes will be followed by 'AM' or 'PM'.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
369
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
370 time-text: The same as above, but will not use a glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
371
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
372 The other specs are simpler, as their meaning is not changed via
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
373 variables.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
374
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
375 24-hours: This prints the hours in 24-hours format
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
376
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
377 24-hours-text: The same as above, but will not use a glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
378
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
379 12-hours: This prints the hours in 12-hours format
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
380
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
381 12-hours-text: The same as above, but will not use a glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
382
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
383 am-pm: This prints am or pm.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
384
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
385 Timezone: This prints out the local timezone
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
386
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
387 am-pm-text: The same as above, but will not use a glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
388
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
389 minutes: This prints the minutes.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
390
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
391 minutes-text: The same as above, but will not use a glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
392
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
393 day: This prints out the current day as a number.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
394
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
395 dayname: This prints out today's name.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
396
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
397 month: This prints out the current month as a number
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
398
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
399 monthname: This prints out the current month's name
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
400
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
401 year: This prints out the current year.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
402
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
403 load: This prints out the system's load.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
404
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
405 load-text: The same as above, but will not use a glyph
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
406
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
407 mail: This displays a mail indicator. Under X this will
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
408 normally be a small icon which changes depending if
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
409 there is new mail or not.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
410
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
411 mail-text: The same as above, but will not use a glyph"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
412 :group 'display-time
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
413 :type '(repeat (choice :tag "Toggle Symbol/String"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
414 (const :tag "Date" date)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
415 (const :tag "Time" time)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
416 (const :tag "Time (text)" time-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
417 (const :tag "24 hour format" 24-hours)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
418 (const :tag "24 hour format (text)" 24-hours-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
419 (const :tag "12 hour format" 12-hours)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
420 (const :tag "12 hour format (text)" 12-hours-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
421 (const :tag "AM/PM indicator" am-pm)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
422 (const :tag "AM/PM indicator (text)" am-pm-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
423 (const :tag "Timezone" timezone)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
424 (const :tag "Minutes" minutes)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
425 (const :tag "Minutes (text)" minutes-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
426 (const :tag "Day" day)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
427 (const :tag "Dayname" dayname)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
428 (const :tag "Month" month)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
429 (const :tag "Monthname" monthname)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
430 (const :tag "Year" year)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
431 (const :tag "Load" load)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
432 (const :tag "Load (text)" load-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
433 (const :tag "Mail sign" mail)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
434 (const :tag "Mail sign (text)" mail-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
435 (string :tag "String"))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
436
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
437 (defun display-time-evaluate-list ()
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
438 "Evalute the variable display-time-form-list"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
439 (let ((list display-time-form-list) elem tmp result)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
440 (while (setq elem (pop list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
441 (cond ((stringp elem) (push elem tmp))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
442 ((eq elem 'date)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
443 (push (if display-time-day-and-date
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
444 (format "%s %s %s " dayname monthname day) "") tmp))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
445 ((eq elem 'time)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
446 (progn
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
447 (push (display-time-convert-num
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
448 (format "%s:%s"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
449 (if display-time-24hr-format 24-hours 12-hours)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
450 minutes)) tmp)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
451 (if (not display-time-24hr-format)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
452 (push (display-time-convert-am-pm am-pm) tmp))))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
453 ((eq elem 'time-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
454 (push (display-time-convert-num
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
455 (format "%s:%s"
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
456 (if display-time-24hr-format 24-hours 12-hours)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
457 minutes) t) tmp)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
458 (if (not display-time-24hr-format)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
459 (push (display-time-convert-am-pm am-pm t) tmp)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
460 ((eq elem 'day) (push day tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
461 ((eq elem 'dayname) (push dayname tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
462 ((eq elem 'month) (push month tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
463 ((eq elem 'monthname) (push monthname tmp))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
464 ((eq elem '24-hours)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
465 (push (display-time-convert-num 24-hours) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
466 ((eq elem 'year)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
467 (push year tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
468 ((eq elem '24-hours-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
469 (push (display-time-convert-num 24-hours t) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
470 ((eq elem '12-hours)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
471 (push (display-time-convert-num 12-hours) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
472 ((eq elem '12-hours-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
473 (push (display-time-convert-num 12-hours t) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
474 ((eq elem 'minutes)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
475 (push (display-time-convert-num minutes) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
476 ((eq elem 'minutes-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
477 (push (display-time-convert-num minutes t) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
478 ((eq elem 'am-pm)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
479 (push (display-time-convert-am-pm am-pm) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
480 ((eq elem 'am-pm-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
481 (push (display-time-convert-am-pm am-pm t) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
482 ((eq elem 'timezone)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
483 (push time-zone tmp))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
484 ((eq elem 'load)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
485 (push (display-time-convert-load load) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
486 ((eq elem 'load-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
487 (push (display-time-convert-load load t) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
488 ((eq elem 'mail)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
489 (push (if mail (display-time-mail-sign)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
490 (display-time-no-mail-sign)) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
491 ((eq elem 'mail-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
492 (push (if mail (display-time-mail-sign t)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
493 (display-time-no-mail-sign t)) tmp))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
494 ))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
495 ;; We know that we have a list containing only of strings if
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
496 ;; display-time-echo-area is t. So we construct this string from
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
497 ;; the list. Else we just reverse the list and give it as result.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
498 (if (not display-time-echo-area) (setq result (reverse tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
499 (while (setq elem (pop tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
500 (setq result (concat elem result))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
501 result))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
502
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
503
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (defvar display-time-string-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 '((if display-time-day-and-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (format "%s %s %s " dayname monthname day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (format "%s:%s%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (if display-time-24hr-format 24-hours 12-hours)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 minutes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (if display-time-24hr-format "" am-pm))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
512 load
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
513 (if mail " Mail" ""))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
514 "*THIS IS OBSOLETE! It will only be used if display-time-compatible is t.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
515 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
516 This expression is a list of expressions that can involve the keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 `load', `day', `month', and `year', `12-hours', `24-hours', `minutes',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 `seconds', all numbers in string form, and `monthname', `dayname', `am-pm',
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
519 and `time-zone' all alphabetic strings and `mail' a true/nil string value.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 For example, the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 '((substring year -2) \"/\" month \"/\" day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 \" \" 24-hours \":\" minutes \":\" seconds
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
525 (if time-zone \" (\") time-zone (if time-zone \")\"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 would give mode line times like `94/12/30 21:07:48 (UTC)'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (defun display-time-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (let* ((now (current-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (time (current-time-string now))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (load (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (if (zerop (car (load-average))) ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (let ((str (format " %03d" (car (load-average)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (concat (substring str 0 -2) "." (substring str -2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (error "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (mail-spool-file (or display-time-mail-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (getenv "MAIL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (concat rmail-spool-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (mail (and (stringp mail-spool-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (or (null display-time-server-down-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ;; If have been down for 20 min, try again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (> (- (nth 1 (current-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 display-time-server-down-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 1200))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (let ((start-time (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (display-time-file-nonempty-p mail-spool-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (if (> (- (nth 1 (current-time)) (nth 1 start-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;; Record that mail file is not accessible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (setq display-time-server-down-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (nth 1 (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;; Record that mail file is accessible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (setq display-time-server-down-time nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (24-hours (substring time 11 13))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (hour (string-to-int 24-hours))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (12-hours (int-to-string (1+ (% (+ hour 11) 12))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (am-pm (if (>= hour 12) "pm" "am"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (minutes (substring time 14 16))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (seconds (substring time 17 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (time-zone (car (cdr (current-time-zone now))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (day (substring time 8 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (year (substring time 20 24))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (monthname (substring time 4 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 monthname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (dayname (substring time 0 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (setq display-time-string
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
576 (if display-time-compatible
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
577 (mapconcat 'eval display-time-string-forms "")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
578 (display-time-evaluate-list)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; This is inside the let binding, but we are not going to document
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; what variables are available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (run-hooks 'display-time-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (if display-time-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (or (> (minibuffer-depth) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ;; don't stomp echo-area-buffer if reading from minibuffer now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (select-window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (erase-buffer)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
589 (indent-to (- (frame-width) (length display-time-string) 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (insert display-time-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (message (buffer-string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (force-mode-line-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; Do redisplay right now, if no input pending.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (sit-for 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (defun display-time-file-nonempty-p (file)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
597 (let ((attributes (file-attributes (file-chase-links file))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
598 (and attributes
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
599 (< 0 (nth 7 attributes))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
600 (or display-time-ignore-read-mail
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
601 (> (car (nth 5 attributes)) (car (nth 4 attributes)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
602 (and (= (car (nth 5 attributes)) (car (nth 4 attributes)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
603 (> (cadr (nth 5 attributes)) (cadr (nth 4 attributes))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (provide 'time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ;;; time.el ends here