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

Import from CVS: tag r20-1b4
author cvs
date Mon, 13 Aug 2007 09:16:51 +0200
parents 131b0175ea99
children 360340f9fd5f
comparison
equal deleted inserted replaced
103:30eda07fe280 104:cf808b4c4290
101 ;; wake up exactly at the minute boundary. But that's just a little 101 ;; wake up exactly at the minute boundary. But that's just a little
102 ;; more work than it's worth... 102 ;; more work than it's worth...
103 (start-itimer "display-time" 'display-time-function 103 (start-itimer "display-time" 'display-time-function
104 display-time-interval display-time-interval)) 104 display-time-interval display-time-interval))
105 105
106 (defvar display-time-show-load t)
107
108 (defvar display-time-show-icons-maybe t
109 "Use icons to indicate the mail status if we're running under X and
110 XEmacs was compiled with xpm support")
111
112 (defun display-time-get-icons-dir ()
113 (let ((path load-path)
114 dir elem)
115 (while (setq elem (pop path))
116 (setq dir (concat (directory-file-name elem) "/../etc/time/"))
117 (if (file-directory-p dir) (setq path nil)
118 nil))
119 dir))
120
121 (defvar display-time-icons-dir (display-time-get-icons-dir))
122
123 (defvar display-time-mail-sign
124 (progn
125 (let* ((file (concat display-time-icons-dir "letter.xpm"))
126 (glyph (if (featurep 'xpm) (make-glyph file) nil))
127 (display-time-mail-ext (detach-extent (make-extent 1 1))))
128 (if (and (featurep 'x) glyph
129 (file-exists-p file))
130 (cons display-time-mail-ext glyph)
131 " Mail")))
132 "A variable holding a string or a cons cell (ext . glyph) which gives
133 an indicator for unread mail. The default displays a xpm-file (a yellow letter)
134 if (feturep 'xpm) and (featurep 'x) are both t, a string \" Mail\" otherwise")
135
136 (defvar display-time-no-mail-sign
137 (progn
138 (let* ((file (concat display-time-icons-dir "no-letter.xpm"))
139 (glyph (if (featurep 'xpm) (make-glyph file) nil))
140 (display-time-mail-ext (detach-extent (make-extent 1 1))))
141 (if (and (featurep 'x) glyph
142 (file-exists-p file))
143 (cons display-time-mail-ext glyph)
144 "")))
145 "A variable holding a string or a cons cell (ext . glyph) which gives
146 an indicator for `no mail'. The default displays a xpm-file
147 if (feturep 'xpm) and (featurep 'x) are both t, and nothing otherwise")
148
149
106 (defvar display-time-string-forms 150 (defvar display-time-string-forms
107 '((if display-time-day-and-date 151 '((if display-time-day-and-date
108 (format "%s %s %s " dayname monthname day) 152 (format "%s %s %s " dayname monthname day)
109 "") 153 "")
110 (format "%s:%s%s" 154 (format "%s:%s%s"
111 (if display-time-24hr-format 24-hours 12-hours) 155 (if display-time-24hr-format 24-hours 12-hours)
112 minutes 156 minutes
113 (if display-time-24hr-format "" am-pm)) 157 (if display-time-24hr-format "" am-pm))
114 load 158 (if display-time-show-load load)
115 (if mail " Mail" "")) 159 (if (and (not display-time-show-icons-maybe) mail) " Mail" ""))
116 "*A list of expressions governing display of the time in the mode line. 160 "*A list of expressions governing display of the time in the mode line.
117 This expression is a list of expressions that can involve the keywords 161 This expression is a list of expressions that can involve the keywords
118 `load', `day', `month', and `year', `12-hours', `24-hours', `minutes', 162 `load', `day', `month', and `year', `12-hours', `24-hours', `minutes',
119 `seconds', all numbers in string form, and `monthname', `dayname', `am-pm', 163 `seconds', all numbers in string form, and `monthname', `dayname', `am-pm',
120 and `time-zone' all alphabetic strings, and `mail' a true/nil value. 164 and `time-zone' all alphabetic strings and `mail' a true/nil string value.
165 Beware: if display-time-show-icons-maybe is non-nil, the `mail' spec is also
166 evaluated after this form and depending on it's result display-time-mail-sign
167 or display-time-no-mail-sign is appended to the modeline string.
168 This was made so you can also use xpm-files as mail indicator.
121 169
122 For example, the form 170 For example, the form
123 171
124 '((substring year -2) \"/\" month \"/\" day 172 '((substring year -2) \"/\" month \"/\" day
125 \" \" 24-hours \":\" minutes \":\" seconds 173 \" \" 24-hours \":\" minutes \":\" seconds
126 (if time-zone \" (\") time-zone (if time-zone \")\") 174 (if time-zone \" (\") time-zone (if time-zone \")\"))
127 (if mail \" Mail\" \"\"))
128 175
129 would give mode line times like `94/12/30 21:07:48 (UTC)'.") 176 would give mode line times like `94/12/30 21:07:48 (UTC)'.")
130 177
131 (defun display-time-function () 178 (defun display-time-function ()
132 (let* ((now (current-time)) 179 (let* ((now (current-time))
174 ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8") 221 ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8")
175 ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12"))))) 222 ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12")))))
176 (dayname (substring time 0 3))) 223 (dayname (substring time 0 3)))
177 (setq display-time-string 224 (setq display-time-string
178 (mapconcat 'eval display-time-string-forms "")) 225 (mapconcat 'eval display-time-string-forms ""))
226 (if (and mail display-time-show-icons-maybe)
227 (setq display-time-string
228 (list display-time-string display-time-mail-sign))
229 (if display-time-show-icons-maybe
230 (setq display-time-string
231 (list display-time-string display-time-no-mail-sign))))
179 ;; This is inside the let binding, but we are not going to document 232 ;; This is inside the let binding, but we are not going to document
180 ;; what variables are available. 233 ;; what variables are available.
181 (run-hooks 'display-time-hook)) 234 (run-hooks 'display-time-hook))
182 (if display-time-echo-area 235 (if display-time-echo-area
183 (or (> (minibuffer-depth) 0) 236 (or (> (minibuffer-depth) 0)