diff options
| author | Stefan Monnier | 2000-06-17 15:36:33 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-06-17 15:36:33 +0000 |
| commit | c2acf685ec1be2c05058cd5fcbe1211446501137 (patch) | |
| tree | 7f16474f11abf90a9913df7048c36c3c010a1a03 /lisp | |
| parent | 0df68e9f5b6b7efcaa1442fd3d139a4ef53ff660 (diff) | |
| download | emacs-c2acf685ec1be2c05058cd5fcbe1211446501137.tar.gz emacs-c2acf685ec1be2c05058cd5fcbe1211446501137.zip | |
Remove trailing ^M that prevent CVS-merging.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/time.el | 628 |
2 files changed, 318 insertions, 314 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 63b861f382f..b62884e10ab 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2000-06-17 Stefan Monnier <monnier@cs.yale.edu> | ||
| 2 | |||
| 3 | * time.el: Remove trailing ^M that prevent CVS-merging. | ||
| 4 | |||
| 1 | 2000-06-16 Stefan Monnier <monnier@cs.yale.edu> | 5 | 2000-06-16 Stefan Monnier <monnier@cs.yale.edu> |
| 2 | 6 | ||
| 3 | * Makefile.in (srcdir): Define for update-subdirs. | 7 | * Makefile.in (srcdir): Define for update-subdirs. |
diff --git a/lisp/time.el b/lisp/time.el index cb276e4097d..756aa6ad8b9 100644 --- a/lisp/time.el +++ b/lisp/time.el | |||
| @@ -1,315 +1,315 @@ | |||
| 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. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1985, 86, 87, 93, 94, 96, 2000 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1985, 86, 87, 93, 94, 96, 2000 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Maintainer: FSF | 5 | ;; Maintainer: FSF |
| 6 | 6 | ||
| 7 | ;; This file is part of GNU Emacs. | 7 | ;; This file is part of GNU Emacs. |
| 8 | 8 | ||
| 9 | ;; GNU Emacs is free software; you can redistribute it and/or modify | 9 | ;; GNU Emacs is free software; you can redistribute it and/or modify |
| 10 | ;; it under the terms of the GNU General Public License as published by | 10 | ;; it under the terms of the GNU General Public License as published by |
| 11 | ;; the Free Software Foundation; either version 2, or (at your option) | 11 | ;; the Free Software Foundation; either version 2, or (at your option) |
| 12 | ;; any later version. | 12 | ;; any later version. |
| 13 | 13 | ||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | 14 | ;; GNU Emacs is distributed in the hope that it will be useful, |
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | ;; GNU General Public License for more details. | 17 | ;; GNU General Public License for more details. |
| 18 | 18 | ||
| 19 | ;; You should have received a copy of the GNU General Public License | 19 | ;; You should have received a copy of the GNU General Public License |
| 20 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | 20 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
| 21 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 22 | ;; Boston, MA 02111-1307, USA. | 22 | ;; Boston, MA 02111-1307, USA. |
| 23 | 23 | ||
| 24 | ;;; Commentary: | 24 | ;;; Commentary: |
| 25 | 25 | ||
| 26 | ;; Facilities to display current time/date and a new-mail indicator | 26 | ;; Facilities to display current time/date and a new-mail indicator |
| 27 | ;; in the Emacs mode line. The single entry point is `display-time'. | 27 | ;; in the Emacs mode line. The single entry point is `display-time'. |
| 28 | 28 | ||
| 29 | ;;; Code: | 29 | ;;; Code: |
| 30 | 30 | ||
| 31 | (defgroup display-time nil | 31 | (defgroup display-time nil |
| 32 | "Display time and load in mode line of Emacs." | 32 | "Display time and load in mode line of Emacs." |
| 33 | :group 'modeline | 33 | :group 'modeline |
| 34 | :group 'mail) | 34 | :group 'mail) |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | ;;;###autoload | 37 | ;;;###autoload |
| 38 | (defcustom display-time-mode nil | 38 | (defcustom display-time-mode nil |
| 39 | "Toggle display of time, load level, and mail flag in mode lines. | 39 | "Toggle display of time, load level, and mail flag in mode lines. |
| 40 | Setting this variable directly does not take effect; | 40 | Setting this variable directly does not take effect; |
| 41 | use either \\[customize] or the function `display-time-mode'." | 41 | use either \\[customize] or the function `display-time-mode'." |
| 42 | :set (lambda (symbol value) | 42 | :set (lambda (symbol value) |
| 43 | (display-time-mode (or value 0))) | 43 | (display-time-mode (or value 0))) |
| 44 | :initialize 'custom-initialize-default | 44 | :initialize 'custom-initialize-default |
| 45 | :type 'boolean | 45 | :type 'boolean |
| 46 | :group 'display-time | 46 | :group 'display-time |
| 47 | :require 'time | 47 | :require 'time |
| 48 | :version "20.3") | 48 | :version "20.3") |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | (defcustom display-time-mail-file nil | 51 | (defcustom display-time-mail-file nil |
| 52 | "*File name of mail inbox file, for indicating existence of new mail. | 52 | "*File name of mail inbox file, for indicating existence of new mail. |
| 53 | Non-nil and not a string means don't check for mail. nil means use | 53 | Non-nil and not a string means don't check for mail. nil means use |
| 54 | default, which is system-dependent, and is the same as used by Rmail." | 54 | default, which is system-dependent, and is the same as used by Rmail." |
| 55 | :type '(choice (const :tag "(None)" none) | 55 | :type '(choice (const :tag "(None)" none) |
| 56 | (const :tag "Default" nil) | 56 | (const :tag "Default" nil) |
| 57 | (file :format "%v")) | 57 | (file :format "%v")) |
| 58 | :group 'display-time) | 58 | :group 'display-time) |
| 59 | 59 | ||
| 60 | (defcustom display-time-mail-function nil | 60 | (defcustom display-time-mail-function nil |
| 61 | "*Function to call, for indicating existence of new mail. | 61 | "*Function to call, for indicating existence of new mail. |
| 62 | nil means use the default method of checking `display-time-mail-file'." | 62 | nil means use the default method of checking `display-time-mail-file'." |
| 63 | :type '(choice (const :tag "Default" nil) | 63 | :type '(choice (const :tag "Default" nil) |
| 64 | (function)) | 64 | (function)) |
| 65 | :group 'display-time) | 65 | :group 'display-time) |
| 66 | 66 | ||
| 67 | ;;;###autoload | 67 | ;;;###autoload |
| 68 | (defcustom display-time-day-and-date nil "\ | 68 | (defcustom display-time-day-and-date nil "\ |
| 69 | *Non-nil means \\[display-time] should display day and date as well as time." | 69 | *Non-nil means \\[display-time] should display day and date as well as time." |
| 70 | :type 'boolean | 70 | :type 'boolean |
| 71 | :group 'display-time) | 71 | :group 'display-time) |
| 72 | 72 | ||
| 73 | (defvar display-time-timer nil) | 73 | (defvar display-time-timer nil) |
| 74 | 74 | ||
| 75 | (defcustom display-time-interval 60 | 75 | (defcustom display-time-interval 60 |
| 76 | "*Seconds between updates of time in the mode line." | 76 | "*Seconds between updates of time in the mode line." |
| 77 | :type 'integer | 77 | :type 'integer |
| 78 | :group 'display-time) | 78 | :group 'display-time) |
| 79 | 79 | ||
| 80 | (defcustom display-time-24hr-format nil | 80 | (defcustom display-time-24hr-format nil |
| 81 | "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. | 81 | "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. |
| 82 | Nil means 1 <= hh <= 12, and an AM/PM suffix is used." | 82 | Nil means 1 <= hh <= 12, and an AM/PM suffix is used." |
| 83 | :type 'boolean | 83 | :type 'boolean |
| 84 | :group 'display-time) | 84 | :group 'display-time) |
| 85 | 85 | ||
| 86 | (defvar display-time-string nil) | 86 | (defvar display-time-string nil) |
| 87 | 87 | ||
| 88 | (defcustom display-time-hook nil | 88 | (defcustom display-time-hook nil |
| 89 | "*List of functions to be called when the time is updated on the mode line." | 89 | "*List of functions to be called when the time is updated on the mode line." |
| 90 | :type 'hook | 90 | :type 'hook |
| 91 | :group 'display-time) | 91 | :group 'display-time) |
| 92 | 92 | ||
| 93 | (defvar display-time-server-down-time nil | 93 | (defvar display-time-server-down-time nil |
| 94 | "Time when mail file's file system was recorded to be down. | 94 | "Time when mail file's file system was recorded to be down. |
| 95 | If that file system seems to be up, the value is nil.") | 95 | If that file system seems to be up, the value is nil.") |
| 96 | 96 | ||
| 97 | ;;;###autoload | 97 | ;;;###autoload |
| 98 | (defun display-time () | 98 | (defun display-time () |
| 99 | "Enable display of time, load level, and mail flag in mode lines. | 99 | "Enable display of time, load level, and mail flag in mode lines. |
| 100 | This display updates automatically every minute. | 100 | This display updates automatically every minute. |
| 101 | If `display-time-day-and-date' is non-nil, the current day and date | 101 | If `display-time-day-and-date' is non-nil, the current day and date |
| 102 | are displayed as well. | 102 | are displayed as well. |
| 103 | This runs the normal hook `display-time-hook' after each update." | 103 | This runs the normal hook `display-time-hook' after each update." |
| 104 | (interactive) | 104 | (interactive) |
| 105 | (display-time-mode 1)) | 105 | (display-time-mode 1)) |
| 106 | 106 | ||
| 107 | ;;;###autoload | 107 | ;;;###autoload |
| 108 | (defun display-time-mode (arg) | 108 | (defun display-time-mode (arg) |
| 109 | "Toggle display of time, load level, and mail flag in mode lines. | 109 | "Toggle display of time, load level, and mail flag in mode lines. |
| 110 | With a numeric arg, enable this display if arg is positive. | 110 | With a numeric arg, enable this display if arg is positive. |
| 111 | 111 | ||
| 112 | When this display is enabled, it updates automatically every minute. | 112 | When this display is enabled, it updates automatically every minute. |
| 113 | If `display-time-day-and-date' is non-nil, the current day and date | 113 | If `display-time-day-and-date' is non-nil, the current day and date |
| 114 | are displayed as well. | 114 | are displayed as well. |
| 115 | This runs the normal hook `display-time-hook' after each update." | 115 | This runs the normal hook `display-time-hook' after each update." |
| 116 | (interactive "P") | 116 | (interactive "P") |
| 117 | (let ((on (if (null arg) | 117 | (let ((on (if (null arg) |
| 118 | (not display-time-timer) | 118 | (not display-time-timer) |
| 119 | (> (prefix-numeric-value arg) 0)))) | 119 | (> (prefix-numeric-value arg) 0)))) |
| 120 | (setq display-time-mode on) | 120 | (setq display-time-mode on) |
| 121 | (and display-time-timer (cancel-timer display-time-timer)) | 121 | (and display-time-timer (cancel-timer display-time-timer)) |
| 122 | (setq display-time-timer nil) | 122 | (setq display-time-timer nil) |
| 123 | (setq display-time-string "") | 123 | (setq display-time-string "") |
| 124 | (or global-mode-string (setq global-mode-string '(""))) | 124 | (or global-mode-string (setq global-mode-string '(""))) |
| 125 | (if on | 125 | (if on |
| 126 | (progn | 126 | (progn |
| 127 | (or (memq 'display-time-string global-mode-string) | 127 | (or (memq 'display-time-string global-mode-string) |
| 128 | (setq global-mode-string | 128 | (setq global-mode-string |
| 129 | (append global-mode-string '(display-time-string)))) | 129 | (append global-mode-string '(display-time-string)))) |
| 130 | ;; Set up the time timer. | 130 | ;; Set up the time timer. |
| 131 | (setq display-time-timer | 131 | (setq display-time-timer |
| 132 | (run-at-time t display-time-interval | 132 | (run-at-time t display-time-interval |
| 133 | 'display-time-event-handler)) | 133 | 'display-time-event-handler)) |
| 134 | ;; Make the time appear right away. | 134 | ;; Make the time appear right away. |
| 135 | (display-time-update) | 135 | (display-time-update) |
| 136 | ;; When you get new mail, clear "Mail" from the mode line. | 136 | ;; When you get new mail, clear "Mail" from the mode line. |
| 137 | (add-hook 'rmail-after-get-new-mail-hook | 137 | (add-hook 'rmail-after-get-new-mail-hook |
| 138 | 'display-time-event-handler)) | 138 | 'display-time-event-handler)) |
| 139 | (remove-hook 'rmail-after-get-new-mail-hook | 139 | (remove-hook 'rmail-after-get-new-mail-hook |
| 140 | 'display-time-event-handler)))) | 140 | 'display-time-event-handler)))) |
| 141 | 141 | ||
| 142 | (defcustom display-time-mail-face 'mode-line | 142 | (defcustom display-time-mail-face 'mode-line |
| 143 | "Face to use for `display-time-mail-string'. | 143 | "Face to use for `display-time-mail-string'. |
| 144 | If `display-time-use-mail-icon' is non-nil, the image's background | 144 | If `display-time-use-mail-icon' is non-nil, the image's background |
| 145 | colour is the background of this face. Set this to a face other than | 145 | colour is the background of this face. Set this to a face other than |
| 146 | `mode-line' to make the mail indicator stand out on a suitable | 146 | `mode-line' to make the mail indicator stand out on a suitable |
| 147 | display." | 147 | display." |
| 148 | :group 'faces | 148 | :group 'faces |
| 149 | :group 'display-time | 149 | :group 'display-time |
| 150 | :type 'face) | 150 | :type 'face) |
| 151 | 151 | ||
| 152 | (defvar display-time-mail-icon | 152 | (defvar display-time-mail-icon |
| 153 | (find-image '((:type xbm :file "letter.xbm" :ascent center))) | 153 | (find-image '((:type xbm :file "letter.xbm" :ascent center))) |
| 154 | "Image specification to offer as the mail indicator on a graphic | 154 | "Image specification to offer as the mail indicator on a graphic |
| 155 | display. See `display-time-use-mail-icon' and | 155 | display. See `display-time-use-mail-icon' and |
| 156 | `display-time-mail-face'.") | 156 | `display-time-mail-face'.") |
| 157 | 157 | ||
| 158 | (defcustom display-time-use-mail-icon nil | 158 | (defcustom display-time-use-mail-icon nil |
| 159 | "Non-nil means use an icon as the mail indicator on a graphic display. | 159 | "Non-nil means use an icon as the mail indicator on a graphic display. |
| 160 | Otherwise use the string \"Mail\". The icon may consume less of the | 160 | Otherwise use the string \"Mail\". The icon may consume less of the |
| 161 | mode line. It is specified by `display-time-mail-icon'." | 161 | mode line. It is specified by `display-time-mail-icon'." |
| 162 | :group 'display-time | 162 | :group 'display-time |
| 163 | :type 'boolean) | 163 | :type 'boolean) |
| 164 | 164 | ||
| 165 | (defcustom display-time-format nil | 165 | (defcustom display-time-format nil |
| 166 | "*A string specifying the format for displaying the time in the mode line. | 166 | "*A string specifying the format for displaying the time in the mode line. |
| 167 | See the function `format-time-string' for an explanation of | 167 | See the function `format-time-string' for an explanation of |
| 168 | how to write this string. If this is nil, the defaults | 168 | how to write this string. If this is nil, the defaults |
| 169 | depend on `display-time-day-and-date' and `display-time-24hr-format'." | 169 | depend on `display-time-day-and-date' and `display-time-24hr-format'." |
| 170 | :type '(choice (const :tag "Default" nil) | 170 | :type '(choice (const :tag "Default" nil) |
| 171 | string) | 171 | string) |
| 172 | :group 'display-time) | 172 | :group 'display-time) |
| 173 | 173 | ||
| 174 | (defcustom display-time-string-forms | 174 | (defcustom display-time-string-forms |
| 175 | '((if (and (not display-time-format) display-time-day-and-date) | 175 | '((if (and (not display-time-format) display-time-day-and-date) |
| 176 | (format-time-string "%a %b %e " now) | 176 | (format-time-string "%a %b %e " now) |
| 177 | "") | 177 | "") |
| 178 | (format-time-string (or display-time-format | 178 | (format-time-string (or display-time-format |
| 179 | (if display-time-24hr-format "%H:%M" "%-I:%M%p")) | 179 | (if display-time-24hr-format "%H:%M" "%-I:%M%p")) |
| 180 | now) | 180 | now) |
| 181 | load | 181 | load |
| 182 | (if mail | 182 | (if mail |
| 183 | ;; Build the string every time to act on customization. | 183 | ;; Build the string every time to act on customization. |
| 184 | (concat " " | 184 | (concat " " |
| 185 | (propertize | 185 | (propertize |
| 186 | "Mail" | 186 | "Mail" |
| 187 | 'display `(when (and display-time-use-mail-icon | 187 | 'display `(when (and display-time-use-mail-icon |
| 188 | (display-graphic-p)) | 188 | (display-graphic-p)) |
| 189 | ,@display-time-mail-icon | 189 | ,@display-time-mail-icon |
| 190 | ,@(list :background (face-attribute | 190 | ,@(list :background (face-attribute |
| 191 | display-time-mail-face | 191 | display-time-mail-face |
| 192 | :background))) | 192 | :background))) |
| 193 | 'help-echo "mouse-2: Read mail" | 193 | 'help-echo "mouse-2: Read mail" |
| 194 | 'local-map (make-mode-line-mouse2-map read-mail-command))) | 194 | 'local-map (make-mode-line-mouse2-map read-mail-command))) |
| 195 | "")) | 195 | "")) |
| 196 | "*A list of expressions governing display of the time in the mode line. | 196 | "*A list of expressions governing display of the time in the mode line. |
| 197 | For most purposes, you can control the time format using `display-time-format' | 197 | For most purposes, you can control the time format using `display-time-format' |
| 198 | which is a more standard interface. | 198 | which is a more standard interface. |
| 199 | 199 | ||
| 200 | This expression is a list of expressions that can involve the keywords | 200 | This expression is a list of expressions that can involve the keywords |
| 201 | `load', `day', `month', and `year', `12-hours', `24-hours', `minutes', | 201 | `load', `day', `month', and `year', `12-hours', `24-hours', `minutes', |
| 202 | `seconds', all numbers in string form, and `monthname', `dayname', `am-pm', | 202 | `seconds', all numbers in string form, and `monthname', `dayname', `am-pm', |
| 203 | and `time-zone' all alphabetic strings, and `mail' a true/nil value. | 203 | and `time-zone' all alphabetic strings, and `mail' a true/nil value. |
| 204 | 204 | ||
| 205 | For example, the form | 205 | For example, the form |
| 206 | 206 | ||
| 207 | '((substring year -2) \"/\" month \"/\" day | 207 | '((substring year -2) \"/\" month \"/\" day |
| 208 | \" \" 24-hours \":\" minutes \":\" seconds | 208 | \" \" 24-hours \":\" minutes \":\" seconds |
| 209 | (if time-zone \" (\") time-zone (if time-zone \")\") | 209 | (if time-zone \" (\") time-zone (if time-zone \")\") |
| 210 | (if mail \" Mail\" \"\")) | 210 | (if mail \" Mail\" \"\")) |
| 211 | 211 | ||
| 212 | would give mode line times like `94/12/30 21:07:48 (UTC)'." | 212 | would give mode line times like `94/12/30 21:07:48 (UTC)'." |
| 213 | :type 'sexp | 213 | :type 'sexp |
| 214 | :group 'display-time) | 214 | :group 'display-time) |
| 215 | 215 | ||
| 216 | (defun display-time-event-handler () | 216 | (defun display-time-event-handler () |
| 217 | (display-time-update) | 217 | (display-time-update) |
| 218 | ;; Do redisplay right now, if no input pending. | 218 | ;; Do redisplay right now, if no input pending. |
| 219 | (sit-for 0) | 219 | (sit-for 0) |
| 220 | (let* ((current (current-time)) | 220 | (let* ((current (current-time)) |
| 221 | (timer display-time-timer) | 221 | (timer display-time-timer) |
| 222 | ;; Compute the time when this timer will run again, next. | 222 | ;; Compute the time when this timer will run again, next. |
| 223 | (next-time (timer-relative-time | 223 | (next-time (timer-relative-time |
| 224 | (list (aref timer 1) (aref timer 2) (aref timer 3)) | 224 | (list (aref timer 1) (aref timer 2) (aref timer 3)) |
| 225 | (* 5 (aref timer 4)) 0))) | 225 | (* 5 (aref timer 4)) 0))) |
| 226 | ;; If the activation time is far in the past, | 226 | ;; If the activation time is far in the past, |
| 227 | ;; skip executions until we reach a time in the future. | 227 | ;; skip executions until we reach a time in the future. |
| 228 | ;; This avoids a long pause if Emacs has been suspended for hours. | 228 | ;; This avoids a long pause if Emacs has been suspended for hours. |
| 229 | (or (> (nth 0 next-time) (nth 0 current)) | 229 | (or (> (nth 0 next-time) (nth 0 current)) |
| 230 | (and (= (nth 0 next-time) (nth 0 current)) | 230 | (and (= (nth 0 next-time) (nth 0 current)) |
| 231 | (> (nth 1 next-time) (nth 1 current))) | 231 | (> (nth 1 next-time) (nth 1 current))) |
| 232 | (and (= (nth 0 next-time) (nth 0 current)) | 232 | (and (= (nth 0 next-time) (nth 0 current)) |
| 233 | (= (nth 1 next-time) (nth 1 current)) | 233 | (= (nth 1 next-time) (nth 1 current)) |
| 234 | (> (nth 2 next-time) (nth 2 current))) | 234 | (> (nth 2 next-time) (nth 2 current))) |
| 235 | (progn | 235 | (progn |
| 236 | (timer-set-time timer (timer-next-integral-multiple-of-time | 236 | (timer-set-time timer (timer-next-integral-multiple-of-time |
| 237 | current display-time-interval) | 237 | current display-time-interval) |
| 238 | display-time-interval) | 238 | display-time-interval) |
| 239 | (timer-activate timer))))) | 239 | (timer-activate timer))))) |
| 240 | 240 | ||
| 241 | ;; Update the display-time info for the mode line | 241 | ;; Update the display-time info for the mode line |
| 242 | ;; but don't redisplay right now. This is used for | 242 | ;; but don't redisplay right now. This is used for |
| 243 | ;; things like Rmail `g' that want to force an update | 243 | ;; things like Rmail `g' that want to force an update |
| 244 | ;; which can wait for the next redisplay. | 244 | ;; which can wait for the next redisplay. |
| 245 | (defun display-time-update () | 245 | (defun display-time-update () |
| 246 | (let* ((now (current-time)) | 246 | (let* ((now (current-time)) |
| 247 | (time (current-time-string now)) | 247 | (time (current-time-string now)) |
| 248 | (load (condition-case () | 248 | (load (condition-case () |
| 249 | (if (zerop (car (load-average))) "" | 249 | (if (zerop (car (load-average))) "" |
| 250 | ;; The load average number is mysterious, so | 250 | ;; The load average number is mysterious, so |
| 251 | ;; propvide some help. | 251 | ;; propvide some help. |
| 252 | (let ((str (format " %03d" (car (load-average))))) | 252 | (let ((str (format " %03d" (car (load-average))))) |
| 253 | (propertize | 253 | (propertize |
| 254 | (concat (substring str 0 -2) "." (substring str -2)) | 254 | (concat (substring str 0 -2) "." (substring str -2)) |
| 255 | 'help-echo "System load average"))) | 255 | 'help-echo "System load average"))) |
| 256 | (error ""))) | 256 | (error ""))) |
| 257 | (mail-spool-file (or display-time-mail-file | 257 | (mail-spool-file (or display-time-mail-file |
| 258 | (getenv "MAIL") | 258 | (getenv "MAIL") |
| 259 | (concat rmail-spool-directory | 259 | (concat rmail-spool-directory |
| 260 | (user-login-name)))) | 260 | (user-login-name)))) |
| 261 | (mail (or (and display-time-mail-function | 261 | (mail (or (and display-time-mail-function |
| 262 | (funcall display-time-mail-function)) | 262 | (funcall display-time-mail-function)) |
| 263 | (and (stringp mail-spool-file) | 263 | (and (stringp mail-spool-file) |
| 264 | (or (null display-time-server-down-time) | 264 | (or (null display-time-server-down-time) |
| 265 | ;; If have been down for 20 min, try again. | 265 | ;; If have been down for 20 min, try again. |
| 266 | (> (- (nth 1 now) display-time-server-down-time) | 266 | (> (- (nth 1 now) display-time-server-down-time) |
| 267 | 1200) | 267 | 1200) |
| 268 | (and (< (nth 1 now) display-time-server-down-time) | 268 | (and (< (nth 1 now) display-time-server-down-time) |
| 269 | (> (- (nth 1 now) display-time-server-down-time) | 269 | (> (- (nth 1 now) display-time-server-down-time) |
| 270 | -64336))) | 270 | -64336))) |
| 271 | (let ((start-time (current-time))) | 271 | (let ((start-time (current-time))) |
| 272 | (prog1 | 272 | (prog1 |
| 273 | (display-time-file-nonempty-p mail-spool-file) | 273 | (display-time-file-nonempty-p mail-spool-file) |
| 274 | (if (> (- (nth 1 (current-time)) (nth 1 start-time)) | 274 | (if (> (- (nth 1 (current-time)) (nth 1 start-time)) |
| 275 | 20) | 275 | 20) |
| 276 | ;; Record that mail file is not accessible. | 276 | ;; Record that mail file is not accessible. |
| 277 | (setq display-time-server-down-time | 277 | (setq display-time-server-down-time |
| 278 | (nth 1 (current-time))) | 278 | (nth 1 (current-time))) |
| 279 | ;; Record that mail file is accessible. | 279 | ;; Record that mail file is accessible. |
| 280 | (setq display-time-server-down-time nil))))))) | 280 | (setq display-time-server-down-time nil))))))) |
| 281 | (24-hours (substring time 11 13)) | 281 | (24-hours (substring time 11 13)) |
| 282 | (hour (string-to-int 24-hours)) | 282 | (hour (string-to-int 24-hours)) |
| 283 | (12-hours (int-to-string (1+ (% (+ hour 11) 12)))) | 283 | (12-hours (int-to-string (1+ (% (+ hour 11) 12)))) |
| 284 | (am-pm (if (>= hour 12) "pm" "am")) | 284 | (am-pm (if (>= hour 12) "pm" "am")) |
| 285 | (minutes (substring time 14 16)) | 285 | (minutes (substring time 14 16)) |
| 286 | (seconds (substring time 17 19)) | 286 | (seconds (substring time 17 19)) |
| 287 | (time-zone (car (cdr (current-time-zone now)))) | 287 | (time-zone (car (cdr (current-time-zone now)))) |
| 288 | (day (substring time 8 10)) | 288 | (day (substring time 8 10)) |
| 289 | (year (substring time 20 24)) | 289 | (year (substring time 20 24)) |
| 290 | (monthname (substring time 4 7)) | 290 | (monthname (substring time 4 7)) |
| 291 | (month | 291 | (month |
| 292 | (cdr | 292 | (cdr |
| 293 | (assoc | 293 | (assoc |
| 294 | monthname | 294 | monthname |
| 295 | '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4") | 295 | '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4") |
| 296 | ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8") | 296 | ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8") |
| 297 | ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12"))))) | 297 | ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12"))))) |
| 298 | (dayname (substring time 0 3))) | 298 | (dayname (substring time 0 3))) |
| 299 | (setq display-time-string | 299 | (setq display-time-string |
| 300 | (mapconcat 'eval display-time-string-forms "")) | 300 | (mapconcat 'eval display-time-string-forms "")) |
| 301 | ;; This is inside the let binding, but we are not going to document | 301 | ;; This is inside the let binding, but we are not going to document |
| 302 | ;; what variables are available. | 302 | ;; what variables are available. |
| 303 | (run-hooks 'display-time-hook)) | 303 | (run-hooks 'display-time-hook)) |
| 304 | (force-mode-line-update)) | 304 | (force-mode-line-update)) |
| 305 | 305 | ||
| 306 | (defun display-time-file-nonempty-p (file) | 306 | (defun display-time-file-nonempty-p (file) |
| 307 | (and (file-exists-p file) | 307 | (and (file-exists-p file) |
| 308 | (< 0 (nth 7 (file-attributes (file-chase-links file)))))) | 308 | (< 0 (nth 7 (file-attributes (file-chase-links file)))))) |
| 309 | 309 | ||
| 310 | (if display-time-mode | 310 | (if display-time-mode |
| 311 | (display-time-mode t)) | 311 | (display-time-mode t)) |
| 312 | 312 | ||
| 313 | (provide 'time) | 313 | (provide 'time) |
| 314 | 314 | ||
| 315 | ;;; time.el ends here | 315 | ;;; time.el ends here |