aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2003-04-01 18:03:13 +0000
committerDave Love2003-04-01 18:03:13 +0000
commitb7eb6e8a164a40c550dc290d1f6904e5b482422b (patch)
tree90451540af2590fc654cfe5fa8b84d8f3cfd5bea
parent19c37f01f8630f4aaed0828af71192fef064127f (diff)
downloademacs-b7eb6e8a164a40c550dc290d1f6904e5b482422b.tar.gz
emacs-b7eb6e8a164a40c550dc290d1f6904e5b482422b.zip
Doc fixes.
(display-time-mail-face): Change :type and default to nil. (display-time-mail-icon): Use pbm, not xbm. (display-time-mail-string): New. (display-time-string-forms): Use display-time-mail-string. Add checks in display property.
-rw-r--r--lisp/time.el120
1 files changed, 76 insertions, 44 deletions
diff --git a/lisp/time.el b/lisp/time.el
index c0b6c6ab6bd..0f7d8d97d90 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -1,6 +1,6 @@
1;;; time.el --- display time, load and mail indicator in mode line of Emacs 1;;; time.el --- display time, load and mail indicator in mode line of Emacs -*-coding: utf-8 -*-
2 2
3;; Copyright (C) 1985, 86, 87, 93, 94, 96, 2000, 2001, 2002 3;; Copyright (C) 1985, 86, 87, 93, 94, 96, 2000, 2001, 2002, 2003
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Maintainer: FSF 6;; Maintainer: FSF
@@ -62,7 +62,7 @@ directory `display-time-mail-directory' contains nonempty files."
62 :group 'display-time) 62 :group 'display-time)
63 63
64(defcustom display-time-default-load-average 0 64(defcustom display-time-default-load-average 0
65 "*Which load-average value will be shown in the mode line. 65 "*Which load average value will be shown in the mode line.
66Almost every system can provide values of load for past 1 minute, past 5 or 66Almost every system can provide values of load for past 1 minute, past 5 or
67past 15 minutes. The default is to display 1 minute load average." 67past 15 minutes. The default is to display 1 minute load average."
68 :type '(choice (const :tag "1 minute load" 0) 68 :type '(choice (const :tag "1 minute load" 0)
@@ -72,7 +72,7 @@ past 15 minutes. The default is to display 1 minute load average."
72 :group 'display-time) 72 :group 'display-time)
73 73
74(defvar display-time-load-average nil 74(defvar display-time-load-average nil
75 "Load average currently being shown in mode line") 75 "Load average currently being shown in mode line.")
76 76
77(defcustom display-time-load-average-threshold 0.1 77(defcustom display-time-load-average-threshold 0.1
78 "*Load-average values below this value won't be shown in the mode line." 78 "*Load-average values below this value won't be shown in the mode line."
@@ -119,30 +119,47 @@ This runs the normal hook `display-time-hook' after each update."
119 (interactive) 119 (interactive)
120 (display-time-mode 1)) 120 (display-time-mode 1))
121 121
122(defcustom display-time-mail-face 'mode-line 122;; This business used to be simpler when all mode lines had the same
123;; face and the image could just be pbm. Now we try to rely on an xpm
124;; image with a transparent background. Otherwise, set the background
125;; for pbm.
126
127(defcustom display-time-mail-face nil
123 "Face to use for `display-time-mail-string'. 128 "Face to use for `display-time-mail-string'.
124If `display-time-use-mail-icon' is non-nil, the image's background 129If `display-time-use-mail-icon' is non-nil, the image's
125colour is the background of this face. Set this to a face other than 130background colour is the background of this face. Set this to
126`mode-line' to make the mail indicator stand out on a suitable 131make the mail indicator stand out on a colour display."
127display."
128 :group 'faces 132 :group 'faces
129 :group 'display-time 133 :group 'display-time
130 :type 'face) 134 :version "21.4"
135 :type '(choice (const :tag "None" nil) face))
131 136
132(defvar display-time-mail-icon 137(defvar display-time-mail-icon
133 (find-image '((:type xpm :file "letter.xpm" :ascent center) 138 (find-image '((:type xpm :file "letter.xpm" :ascent center)
134 (:type xbm :file "letter.xbm" :ascent center))) 139 (:type pbm :file "letter.pbm" :ascent center)))
135 "Image specification to offer as the mail indicator on a graphic 140 "Image specification to offer as the mail indicator on a graphic display.
136display. See `display-time-use-mail-icon' and 141See `display-time-use-mail-icon' and `display-time-mail-face'.")
137`display-time-mail-face'.")
138 142
143;; Fixme: Default to icon on graphical display?
139(defcustom display-time-use-mail-icon nil 144(defcustom display-time-use-mail-icon nil
140 "Non-nil means use an icon as the mail indicator on a graphic display. 145 "Non-nil means use an icon as the mail indicator on a graphic display.
141Otherwise use the string \"Mail\". The icon may consume less of the 146Otherwise use `display-time-mail-string'. The icon may consume less
142mode line. It is specified by `display-time-mail-icon'." 147of the mode line. It is specified by `display-time-mail-icon'."
143 :group 'display-time 148 :group 'display-time
144 :type 'boolean) 149 :type 'boolean)
145 150
151;; Fixme: maybe default to the character if we can display Unicode.
152(defcustom display-time-mail-string "Mail"
153 "String to use as the mail indicator in `display-time-string-forms'.
154This can use the Unicode letter character if you can display it."
155 :group 'display-time
156 :version "21.4"
157 :type '(choice (const "Mail")
158 ;; Use :tag here because the Lucid menu won't display
159 ;; multibyte text.
160 (const :tag "Unicode letter character" "✉")
161 string))
162
146(defcustom display-time-format nil 163(defcustom display-time-format nil
147 "*A string specifying the format for displaying the time in the mode line. 164 "*A string specifying the format for displaying the time in the mode line.
148See the function `format-time-string' for an explanation of 165See the function `format-time-string' for an explanation of
@@ -162,19 +179,27 @@ depend on `display-time-day-and-date' and `display-time-24hr-format'."
162 load 179 load
163 (if mail 180 (if mail
164 ;; Build the string every time to act on customization. 181 ;; Build the string every time to act on customization.
165 (concat " " 182 ;; :set-after doesn't help for `customize-option'. I think it
166 (propertize 183 ;; should.
167 "Mail" 184 (concat
168 'display `(when (and display-time-use-mail-icon 185 " "
169 (display-graphic-p)) 186 (propertize
170 ,@display-time-mail-icon 187 display-time-mail-string
171 ,@(list :background (face-attribute 188 'display `(when (and display-time-use-mail-icon
172 display-time-mail-face 189 (display-graphic-p))
173 :background))) 190 ,@display-time-mail-icon
174 'face display-time-mail-face 191 ,@(if (and display-time-mail-face
175 'help-echo "You have new mail; mouse-2: Read mail" 192 (memq (plist-get (cdr display-time-mail-icon)
176 'local-map (make-mode-line-mouse-map 'mouse-2 193 :type)
177 read-mail-command))) 194 '(pbm xbm)))
195 (let ((bg (face-attribute display-time-mail-face
196 :background)))
197 (if (stringp bg)
198 (list :background bg)))))
199 'face display-time-mail-face
200 'help-echo "You have new mail; mouse-2: Read mail"
201 'local-map (make-mode-line-mouse-map 'mouse-2
202 read-mail-command)))
178 "")) 203 ""))
179 "*A list of expressions governing display of the time in the mode line. 204 "*A list of expressions governing display of the time in the mode line.
180For most purposes, you can control the time format using `display-time-format' 205For most purposes, you can control the time format using `display-time-format'
@@ -241,11 +266,12 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'."
241 size 266 size
242 nil))) 267 nil)))
243 268
244;; Update the display-time info for the mode line
245;; but don't redisplay right now. This is used for
246;; things like Rmail `g' that want to force an update
247;; which can wait for the next redisplay.
248(defun display-time-update () 269(defun display-time-update ()
270 "Update the display-time info for the mode line.
271However, don't redisplay right now.
272
273This is used for things like Rmail `g' that want to force an
274update which can wait for the next redisplay."
249 (let* ((now (current-time)) 275 (let* ((now (current-time))
250 (time (current-time-string now)) 276 (time (current-time-string now))
251 (load (if (null display-time-load-average) 277 (load (if (null display-time-load-average)
@@ -258,17 +284,21 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'."
258 "" 284 ""
259 ;; The load average number is mysterious, so 285 ;; The load average number is mysterious, so
260 ;; provide some help. 286 ;; provide some help.
261 (let ((str (format " %03d" (nth display-time-load-average (load-average))))) 287 (let ((str (format " %03d"
288 (nth display-time-load-average
289 (load-average)))))
262 (propertize 290 (propertize
263 (concat (substring str 0 -2) "." (substring str -2)) 291 (concat (substring str 0 -2) "." (substring str -2))
264 'local-map (make-mode-line-mouse-map 'mouse-2 292 'local-map (make-mode-line-mouse-map
265 'display-time-next-load-average) 293 'mouse-2 'display-time-next-load-average)
266 'help-echo (concat "System load average for past " 294 'help-echo (concat
267 (if (= 0 display-time-load-average) 295 "System load average for past "
268 "1 minute" 296 (if (= 0 display-time-load-average)
269 (if (= 1 display-time-load-average) 297 "1 minute"
270 "5 minutes" 298 (if (= 1 display-time-load-average)
271 "15 minutes")) "; mouse-2: next" )))) 299 "5 minutes"
300 "15 minutes"))
301 "; mouse-2: next"))))
272 (error "")))) 302 (error ""))))
273 (mail-spool-file (or display-time-mail-file 303 (mail-spool-file (or display-time-mail-file
274 (getenv "MAIL") 304 (getenv "MAIL")
@@ -284,12 +314,14 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'."
284 (> (- (nth 1 now) display-time-server-down-time) 314 (> (- (nth 1 now) display-time-server-down-time)
285 1200) 315 1200)
286 (and (< (nth 1 now) display-time-server-down-time) 316 (and (< (nth 1 now) display-time-server-down-time)
287 (> (- (nth 1 now) display-time-server-down-time) 317 (> (- (nth 1 now)
318 display-time-server-down-time)
288 -64336))) 319 -64336)))
289 (let ((start-time (current-time))) 320 (let ((start-time (current-time)))
290 (prog1 321 (prog1
291 (display-time-file-nonempty-p mail-spool-file) 322 (display-time-file-nonempty-p mail-spool-file)
292 (if (> (- (nth 1 (current-time)) (nth 1 start-time)) 323 (if (> (- (nth 1 (current-time))
324 (nth 1 start-time))
293 20) 325 20)
294 ;; Record that mail file is not accessible. 326 ;; Record that mail file is not accessible.
295 (setq display-time-server-down-time 327 (setq display-time-server-down-time