+ (display-time-mode 1))
+
+;; This business used to be simpler when all mode lines had the same
+;; face and the image could just be pbm. Now we try to rely on an xpm
+;; image with a transparent background. Otherwise, set the background
+;; for pbm.
+
+(defcustom display-time-mail-face nil
+ "Face to use for `display-time-mail-string'.
+If `display-time-use-mail-icon' is non-nil, the image's
+background color is the background of this face. Set this to
+make the mail indicator stand out on a color display."
+ :group 'faces
+ :group 'display-time
+ :version "22.1"
+ :type '(choice (const :tag "None" nil) face))
+
+(defvar display-time-mail-icon
+ (find-image '((:type xpm :file "letter.xpm" :ascent center)
+ (:type pbm :file "letter.pbm" :ascent center)))
+ "Image specification to offer as the mail indicator on a graphic display.
+See `display-time-use-mail-icon' and `display-time-mail-face'.")
+
+;; Fixme: Default to icon on graphical display?
+(defcustom display-time-use-mail-icon nil
+ "Non-nil means use an icon as mail indicator on a graphic display.
+Otherwise use `display-time-mail-string'. The icon may consume less
+of the mode line. It is specified by `display-time-mail-icon'."
+ :group 'display-time
+ :type 'boolean)
+
+;; Fixme: maybe default to the character if we can display Unicode.
+(defcustom display-time-mail-string "Mail"
+ "String to use as the mail indicator in `display-time-string-forms'.
+This can use the Unicode letter character if you can display it."
+ :group 'display-time
+ :version "22.1"
+ :type '(choice (const "Mail")
+ ;; Use :tag here because the Lucid menu won't display
+ ;; multibyte text.
+ (const :tag "Unicode letter character" "✉")
+ string))
+
+(defcustom display-time-format nil
+ "*String specifying format for displaying the time in the mode line.
+See the function `format-time-string' for an explanation of
+how to write this string. If this is nil, the defaults
+depend on `display-time-day-and-date' and `display-time-24hr-format'."
+ :type '(choice (const :tag "Default" nil)
+ string)
+ :group 'display-time)
+
+(defcustom display-time-string-forms
+ '((if (and (not display-time-format) display-time-day-and-date)
+ (format-time-string "%a %b %e " now)
+ "")
+ (propertize
+ (format-time-string (or display-time-format
+ (if display-time-24hr-format "%H:%M" "%-I:%M%p"))
+ now)
+ 'help-echo (format-time-string "%a %b %e, %Y" now))
+ load
+ (if mail
+ ;; Build the string every time to act on customization.
+ ;; :set-after doesn't help for `customize-option'. I think it
+ ;; should.
+ (concat
+ " "
+ (propertize
+ display-time-mail-string
+ 'display `(when (and display-time-use-mail-icon
+ (display-graphic-p))
+ ,@display-time-mail-icon
+ ,@(if (and display-time-mail-face
+ (memq (plist-get (cdr display-time-mail-icon)
+ :type)
+ '(pbm xbm)))
+ (let ((bg (face-attribute display-time-mail-face
+ :background)))
+ (if (stringp bg)
+ (list :background bg)))))
+ 'face display-time-mail-face
+ 'help-echo "You have new mail; mouse-2: Read mail"
+ 'mouse-face 'mode-line-highlight
+ 'local-map (make-mode-line-mouse-map 'mouse-2
+ read-mail-command)))
+ ""))
+ "*List of expressions governing display of the time in the mode line.
+For most purposes, you can control the time format using `display-time-format'
+which is a more standard interface.
+
+This expression is a list of expressions that can involve the keywords
+`load', `day', `month', and `year', `12-hours', `24-hours', `minutes',
+`seconds', all numbers in string form, and `monthname', `dayname', `am-pm',
+and `time-zone' all alphabetic strings, and `mail' a true/nil value.
+
+For example, the form
+
+ '((substring year -2) \"/\" month \"/\" day
+ \" \" 24-hours \":\" minutes \":\" seconds
+ (if time-zone \" (\") time-zone (if time-zone \")\")
+ (if mail \" Mail\" \"\"))
+
+would give mode line times like `94/12/30 21:07:48 (UTC)'."
+ :type 'sexp
+ :group 'display-time)
+
+(defun display-time-event-handler ()
+ (display-time-update)
+ ;; Do redisplay right now, if no input pending.
+ (sit-for 0)
+ (let* ((current (current-time))
+ (timer display-time-timer)
+ ;; Compute the time when this timer will run again, next.
+ (next-time (timer-relative-time
+ (list (aref timer 1) (aref timer 2) (aref timer 3))
+ (* 5 (aref timer 4)) 0)))
+ ;; If the activation time is far in the past,
+ ;; skip executions until we reach a time in the future.
+ ;; This avoids a long pause if Emacs has been suspended for hours.
+ (or (> (nth 0 next-time) (nth 0 current))
+ (and (= (nth 0 next-time) (nth 0 current))
+ (> (nth 1 next-time) (nth 1 current)))
+ (and (= (nth 0 next-time) (nth 0 current))
+ (= (nth 1 next-time) (nth 1 current))
+ (> (nth 2 next-time) (nth 2 current)))