annotate lisp/packages/time.el @ 108:360340f9fd5f r20-1b6

Import from CVS: tag r20-1b6
author cvs
date Mon, 13 Aug 2007 09:18:39 +0200
parents cf808b4c4290
children fe104dbd9147
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
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
45 (defvar display-time-compatible nil
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
46 "*This variable may be set to nil to get the old behaviour of display-time.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
47 This means no display of a spiffy mail icon or use of the display-time-form-list
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
48 instead of the old display-time-string-form.")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
49
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
50 (defvar display-time-mail-file nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "*File name of mail inbox file, for indicating existence of new mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 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
53 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
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;;###autoload
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
56 (defvar display-time-day-and-date nil "\
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
57 *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
58
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
59 (defvar display-time-interval 20
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
60 "*Seconds between updates of time in the mode line.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
62 (defvar display-time-24hr-format nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "*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
64 Nil means 1 <= hh <= 12, and an AM/PM suffix is used.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
66 (defvar display-time-echo-area nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
67 "*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
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defvar display-time-string nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
71 (defvar display-time-hook nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
72 "*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
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (defvar display-time-server-down-time nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 "Time when mail file's file system was recorded to be down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 If that file system seems to be up, the value is nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun display-time ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "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
81 Updates automatically every minute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 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
83 are displayed as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 After each update, `display-time-hook' is run with `run-hooks'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 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
86 echo area instead of in the mode-line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; if the "display-time" itimer already exists, nuke it first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (let ((old (get-itimer "display-time")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (if old (delete-itimer old)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
91
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
92 (if (memq 'display-time-string global-mode-string)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
93 (setq global-mode-string
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
94 (remove 'display-time-string global-mode-string)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; If we're not displaying the time in the echo area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; and the global mode string does not have a non-nil value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; then initialize the global mode string's value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (or display-time-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 global-mode-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (setq global-mode-string '("")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; If we're not displaying the time in the echo area
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
102 ;; 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
103 ;; appear on the modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (or display-time-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (setq global-mode-string
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
106 (append global-mode-string '(display-time-string))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; Display the time initially...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (display-time-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; ... and start an itimer to do it automatically thereafter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; 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
112 ;; not be automatically restarted, but have it re-add itself each time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; Then we could look at (current-time) and arrange for the itimer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; wake up exactly at the minute boundary. But that's just a little
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; more work than it's worth...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (start-itimer "display-time" 'display-time-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 display-time-interval display-time-interval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
119 (defvar display-time-show-icons-maybe t
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
120 "Use icons to indicate the mail status if possible")
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
121
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
122 (defvar display-time-icons-dir (concat data-directory "time/"))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
123
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
124 (defvar display-time-mail-sign-string " Mail"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
125 "The string used as mail indicator in the echo area
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
126 (and in the modeline if display-time-show-icons-maybe is nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
127 if display-time-echo-area is t")
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
128
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
129 (defvar display-time-no-mail-sign-string ""
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
130 "The string used as no-mail indicator in the echo area
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
131 (and in the modeline if display-time-show-icons-maybe is nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
132 if display-time-echo-area is t")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
133
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
134 (defvar display-time-mail-sign
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
135 (progn
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
136 (let* ((file (concat display-time-icons-dir "letter.xpm"))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
137 (glyph (if (featurep 'xpm) (make-glyph file)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
138 display-time-mail-sign-string))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
139 (ext (make-extent nil nil)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
140 (cons ext glyph)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
141 "A variable holding a cons cell (ext . glyph)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
142 which gives an indicator for new mail in the modeline")
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
143
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
144 (defvar display-time-no-mail-sign
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
145 (progn
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
146 (let* ((file (concat display-time-icons-dir "no-letter.xpm"))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
147 (glyph (if (featurep 'xpm) (make-glyph file)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
148 display-time-no-mail-sign-string))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
149 (ext (make-extent nil nil)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
150 (cons ext glyph)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
151 "A variable holding a cons cell (ext . glyph) which gives
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
152 an indicator for `no mail' in the modeline")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
153
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
154 (defun display-time-string-to-char-list (str)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
155 (mapcar (function identity) str))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
156
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
157
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
158 (if (featurep 'xpm)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
159 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
160 (setq display-time-1-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
161 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
162 (make-glyph (concat display-time-icons-dir "1.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
163 (setq display-time-2-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
164 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
165 (make-glyph (concat display-time-icons-dir "2.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
166 (setq display-time-3-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
167 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
168 (make-glyph (concat display-time-icons-dir "3.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
169 (setq display-time-4-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
170 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
171 (make-glyph (concat display-time-icons-dir "4.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
172 (setq display-time-5-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
173 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
174 (make-glyph (concat display-time-icons-dir "5.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
175 (setq display-time-6-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
176 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
177 (make-glyph (concat display-time-icons-dir "6.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
178 (setq display-time-7-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
179 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
180 (make-glyph (concat display-time-icons-dir "7.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
181 (setq display-time-8-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
182 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
183 (make-glyph (concat display-time-icons-dir "8.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
184 (setq display-time-9-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
185 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
186 (make-glyph (concat display-time-icons-dir "9.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
187 (setq display-time-0-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
188 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
189 (make-glyph (concat display-time-icons-dir "0.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
190 (setq display-time-:-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
191 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
192 (make-glyph (concat display-time-icons-dir "dp.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
193 (setq display-time-load-0.0-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
194 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
195 (make-glyph (concat display-time-icons-dir "l-0.0.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
196 (setq display-time-load-0.5-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
197 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
198 (make-glyph (concat display-time-icons-dir "l-0.5.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
199 (setq display-time-load-1.0-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
200 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
201 (make-glyph (concat display-time-icons-dir "l-1.0.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
202 (setq display-time-load-1.5-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
203 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
204 (make-glyph (concat display-time-icons-dir "l-1.5.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
205 (setq display-time-load-2.0-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
206 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
207 (make-glyph (concat display-time-icons-dir "l-2.0.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
208 (setq display-time-load-2.5-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
209 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
210 (make-glyph (concat display-time-icons-dir "l-2.5.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
211 (setq display-time-load-3.0-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
212 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
213 (make-glyph (concat display-time-icons-dir "l-3.0.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
214 (setq display-time-am-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
215 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
216 (make-glyph (concat display-time-icons-dir "am.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
217 (setq display-time-pm-glyph
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
218 (cons (make-extent nil nil)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
219 (make-glyph (concat display-time-icons-dir "pm.xpm"))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
220 ))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
221
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
222
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
223 (defun display-time-convert-num-to-pics (string)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
224 (let ((list (display-time-string-to-char-list string))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
225 elem result tmp)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
226 (if (not (and display-time-show-icons-maybe
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
227 (eq (console-type) 'x)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
228 (not display-time-echo-area))) string
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
229 (while (setq elem (pop list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
230 (push (eval (intern-soft (concat "display-time-"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
231 (char-to-string elem)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
232 "-glyph"))) tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
233 (setq result (reverse tmp)))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
234
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
235 (defvar display-time-load-list
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
236 (list 0.2 0.5 0.8 1.1 1.8 2.6)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
237 "*A list giving six thresholds for the load which correspond
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
238 to the six different icons to be displayed as a load indicator")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
239
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
240 (defun display-time-convert-load-to-glyph (n)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
241 (let ((load-number (string-to-number n))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
242 (alist (list (cons 0.0 0.0)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
243 (cons 0.5 (car display-time-load-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
244 (cons 1.0 (cadr display-time-load-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
245 (cons 1.5 (caddr display-time-load-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
246 (cons 2.0 (cadddr display-time-load-list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
247 (cons 2.5 (cadr (cdddr display-time-load-list)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
248 (cons 3.0 (caddr (cdddr display-time-load-list)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
249 (cons 100000 100000)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
250 result elem)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
251 (if (not (and display-time-show-icons-maybe
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
252 (eq (console-type) 'x)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
253 (not display-time-echo-area))) n
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
254 (while (>= load-number (cdr (setq elem (pop alist))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
255 (setq result (eval (intern-soft (concat
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
256 "display-time-load-"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
257 (number-to-string (car elem))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
258 "-glyph")))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
259 result)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
260
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
261 (defun display-time-convert-am-pm (n)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
262 (if (not (and display-time-show-icons-maybe
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
263 (eq (console-type) 'x)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
264 (not display-time-echo-area))) n
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
265 (cond ((equal n "am") display-time-am-glyph)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
266 ((equal n "pm") display-time-pm-glyph))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
267
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
268
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
269 (defun display-time-mail-sign ()
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
270 "*A function giving back the object indicating 'mail' which
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
271 is the value of display-time-mail-sign when running under X,
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
272 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
273 It is the value of display-time-mail-sign-string otherwise."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
274 (if (or (not (eq (console-type) 'x))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
275 display-time-echo-area
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
276 (not display-time-show-icons-maybe))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
277 display-time-mail-sign-string
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
278 display-time-mail-sign))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
279
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
280 (defun display-time-no-mail-sign ()
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
281 "*A function giving back the object indicating 'no mail' which
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
282 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
283 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
284 It is the value of display-time-no-mail-sign-string otherwise."
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
285 (if (or (not (eq (console-type) 'x))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
286 display-time-echo-area
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
287 (not display-time-show-icons-maybe))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
288 display-time-no-mail-sign-string
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
289 display-time-no-mail-sign))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
290
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
291 (defvar display-time-form-list
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
292 (list 'date-compatible 'time-compatible 'load 'mail)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
293 "*This list describes the format of the strings/glyphs which are to be
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
294 displayed by display-time. The old variable display-time-string-forms is
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
295 only used if display-time-compatible is non-nil. It is a list consisting of
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
296 strings or any of the following symbols:
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
297
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
298 date-compatible: This prints out the date in a manner compatible to
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
299 the default value of the obsolete variable
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
300 display-time-string-forms. It respects the variable
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
301 display-time-day-and-date. If this is t it will print
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
302 out the current date in the form DAYNAME MONTH DAY
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
303 otherwise it will print nothing.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
304
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
305 time-compatible: This prints out the time in a manner compatible to
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
306 the default value of the obsolete variable
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
307 display-time-string-forms. It respects the variable
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
308 display-time-24hr-format. If this is t it will print
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
309 out the current hours in 24-hour format, if nil the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
310 hours will be printed in 12-hour format and the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
311 minutes will be followed by 'AM' or 'PM'.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
312
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
313 24-hours: This prints the hours in 24-hours format
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
314
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
315 12-hours: This prints the hours in 12-hours format
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
316
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
317 am-pm: This prints Am or Pm.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
318
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
319 dp: This prints a \":\", maybe as an icon
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
320
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
321 minutes: This prints the minutes.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
322
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
323 day: This prints out the current day as a number.
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 dayname: This prints out today's name.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
326
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
327 month: This prints out the current month as a number
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
328
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
329 monthname: This prints out the current month's name
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
330
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
331 load: This prints out the system's load.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
332
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
333 mail: This displays a mail indicator. Under X this will
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
334 normally be a small icon which changes depending if
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
335 there is new mail or not.")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
336
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
337 (defun display-time-evaluate-list ()
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
338 "Evalute the variable display-time-form-list"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
339 (let ((list display-time-form-list) elem tmp result)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
340 (while (setq elem (pop list))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
341 (cond ((stringp elem) (push elem tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
342 ((eq elem 'date-compatible)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
343 (push (if display-time-day-and-date
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
344 (format "%s %s %s " dayname monthname day) "") tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
345 ((eq elem 'time-compatible)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
346 (progn
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
347 (push (display-time-convert-num-to-pics
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
348 (format "%s:%s"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
349 (if display-time-24hr-format 24-hours 12-hours)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
350 minutes)) tmp)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
351 (if (not display-time-24hr-format)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
352 (push (display-time-convert-am-pm am-pm) tmp))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
353 ((eq elem 'day) (push day tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
354 ((eq elem 'dayname) (push dayname tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
355 ((eq elem 'month) (push month tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
356 ((eq elem 'monthname) (push monthname tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
357 ((eq elem '24-hours) (push (display-time-convert-num-to-pics 24-hours)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
358 tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
359 ((eq elem '12-hours) (push (display-time-convert-num-to-pics 12-hours)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
360 tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
361 ((eq elem 'minutes) (push (display-time-convert-num-to-pics minutes)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
362 tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
363 ((eq elem 'am-pm) (push am-pm tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
364 ((eq elem 'dp) (push (display-time-convert-num-to-pics ":") tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
365 ((eq elem 'load)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
366 (push (display-time-convert-load-to-glyph load) tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
367 ((eq elem 'mail) (push (if mail (display-time-mail-sign)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
368 (display-time-no-mail-sign))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
369 tmp))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
370 ;; We know that we have a list containing only of strings if
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
371 ;; display-time-echo-area is t. So we construct this string from
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
372 ;; 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
373 (if (not display-time-echo-area) (setq result (reverse tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
374 (while (setq elem (pop tmp))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
375 (setq result (concat elem result))))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
376 result))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
377
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
378
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defvar display-time-string-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 '((if display-time-day-and-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (format "%s %s %s " dayname monthname day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (format "%s:%s%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (if display-time-24hr-format 24-hours 12-hours)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 minutes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (if display-time-24hr-format "" am-pm))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
387 load
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
388 (if mail " Mail" ""))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
389 "*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
390 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
391 This expression is a list of expressions that can involve the keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 `load', `day', `month', and `year', `12-hours', `24-hours', `minutes',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 `seconds', all numbers in string form, and `monthname', `dayname', `am-pm',
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
394 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
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 For example, the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 '((substring year -2) \"/\" month \"/\" day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 \" \" 24-hours \":\" minutes \":\" seconds
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 70
diff changeset
400 (if time-zone \" (\") time-zone (if time-zone \")\"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 would give mode line times like `94/12/30 21:07:48 (UTC)'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (defun display-time-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (let* ((now (current-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (time (current-time-string now))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (load (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if (zerop (car (load-average))) ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (let ((str (format " %03d" (car (load-average)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (concat (substring str 0 -2) "." (substring str -2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (error "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (mail-spool-file (or display-time-mail-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (getenv "MAIL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (concat rmail-spool-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (mail (and (stringp mail-spool-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (or (null display-time-server-down-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;; If have been down for 20 min, try again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (> (- (nth 1 (current-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 display-time-server-down-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 1200))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (let ((start-time (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (display-time-file-nonempty-p mail-spool-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if (> (- (nth 1 (current-time)) (nth 1 start-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; Record that mail file is not accessible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (setq display-time-server-down-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (nth 1 (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; Record that mail file is accessible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (setq display-time-server-down-time nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (24-hours (substring time 11 13))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (hour (string-to-int 24-hours))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (12-hours (int-to-string (1+ (% (+ hour 11) 12))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (am-pm (if (>= hour 12) "pm" "am"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (minutes (substring time 14 16))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (seconds (substring time 17 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (time-zone (car (cdr (current-time-zone now))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (day (substring time 8 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (year (substring time 20 24))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (monthname (substring time 4 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 monthname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (dayname (substring time 0 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (setq display-time-string
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
451 (if display-time-compatible
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
452 (mapconcat 'eval display-time-string-forms "")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
453 (display-time-evaluate-list)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;; This is inside the let binding, but we are not going to document
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;; what variables are available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (run-hooks 'display-time-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (if display-time-echo-area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (or (> (minibuffer-depth) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;; don't stomp echo-area-buffer if reading from minibuffer now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (select-window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (erase-buffer)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
464 (indent-to (- (screen-width) (length display-time-string) 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (insert display-time-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (message (buffer-string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (force-mode-line-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; Do redisplay right now, if no input pending.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (sit-for 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (defun display-time-file-nonempty-p (file)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
472 (and (file-exists-p file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 42
diff changeset
473 (< 0 (nth 7 (file-attributes (file-chase-links file))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (provide 'time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;;; time.el ends here