Mercurial > emacs
annotate lisp/time.el @ 29011:b60861d6c1e0
(fontset_ref): Use SPLIT_CHAR instead of
SPLIT_NON_ASCII_CHAR.
(fontset_ref_via_base, fontset_set): Likewise
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sat, 20 May 2000 00:00:49 +0000 |
parents | 5f062d58a68a |
children | e7c50747bb2d |
rev | line source |
---|---|
28826 | 1 ;;; time.el --- display time, load and mail indicator in mode line of Emacs. |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
387
diff
changeset
|
2 |
27239
c681a4318a92
(display-time-string-forms): Make the Mail string active.
Dave Love <fx@gnu.org>
parents:
25825
diff
changeset
|
3 ;; Copyright (C) 1985, 86, 87, 93, 94, 96, 2000 Free Software Foundation, Inc. |
841 | 4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; Maintainer: FSF |
104 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
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 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
11 ;; the Free Software Foundation; either version 2, or (at your option) |
104 | 12 ;; any later version. |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
104 | 23 |
2319
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2293
diff
changeset
|
24 ;;; Commentary: |
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2293
diff
changeset
|
25 |
14169 | 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'. | |
2319
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2293
diff
changeset
|
28 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
29 ;;; Code: |
104 | 30 |
17697 | 31 (defgroup display-time nil |
32 "Display time and load in mode line of Emacs." | |
33 :group 'modeline | |
34 :group 'mail) | |
35 | |
36 | |
25825
464b296e0b87
(display-time-mode): Add autoload cookie.
Dave Love <fx@gnu.org>
parents:
24693
diff
changeset
|
37 ;;;###autoload |
20583
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
38 (defcustom display-time-mode nil |
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
39 "Toggle display of time, load level, and mail flag in mode lines. |
24647 | 40 Setting this variable directly does not take effect; |
41 use either \\[customize] or the function `display-time-mode'." | |
20583
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
42 :set (lambda (symbol value) |
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
43 (display-time-mode (or value 0))) |
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
44 :initialize 'custom-initialize-default |
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
45 :type 'boolean |
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
46 :group 'display-time |
21670
808ecc2eaa84
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20583
diff
changeset
|
47 :require 'time |
808ecc2eaa84
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20583
diff
changeset
|
48 :version "20.3") |
20583
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
49 |
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
50 |
17697 | 51 (defcustom display-time-mail-file nil |
132
0cbdae7c532f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
104
diff
changeset
|
52 "*File name of mail inbox file, for indicating existence of new mail. |
9581
a035cc3716a1
(display-time-filter): Ignore mail-spool-file if not string.
Richard M. Stallman <rms@gnu.org>
parents:
8804
diff
changeset
|
53 Non-nil and not a string means don't check for mail. nil means use |
17697 | 54 default, which is system-dependent, and is the same as used by Rmail." |
27964
c9d52e101c13
(display-time-mail-file): Add `none' to the list of
Gerd Moellmann <gerd@gnu.org>
parents:
27547
diff
changeset
|
55 :type '(choice (const :tag "(None)" none) |
c9d52e101c13
(display-time-mail-file): Add `none' to the list of
Gerd Moellmann <gerd@gnu.org>
parents:
27547
diff
changeset
|
56 (const :tag "Default" nil) |
17697 | 57 (file :format "%v")) |
58 :group 'display-time) | |
132
0cbdae7c532f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
104
diff
changeset
|
59 |
268 | 60 ;;;###autoload |
17697 | 61 (defcustom display-time-day-and-date nil "\ |
62 *Non-nil means \\[display-time] should display day and date as well as time." | |
63 :type 'boolean | |
64 :group 'display-time) | |
256 | 65 |
14471
c1154020b9c3
(display-time): Rewrite to use built-in timers.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 (defvar display-time-timer nil) |
104 | 67 |
17697 | 68 (defcustom display-time-interval 60 |
69 "*Seconds between updates of time in the mode line." | |
70 :type 'integer | |
71 :group 'display-time) | |
104 | 72 |
17697 | 73 (defcustom display-time-24hr-format nil |
8804
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
74 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. |
17697 | 75 Nil means 1 <= hh <= 12, and an AM/PM suffix is used." |
76 :type 'boolean | |
77 :group 'display-time) | |
387 | 78 |
104 | 79 (defvar display-time-string nil) |
80 | |
17697 | 81 (defcustom display-time-hook nil |
19486
31fbf3a289c1
(display-time-hook): Minor doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18566
diff
changeset
|
82 "*List of functions to be called when the time is updated on the mode line." |
17697 | 83 :type 'hook |
84 :group 'display-time) | |
104 | 85 |
5463
e277328474cc
(display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents:
4014
diff
changeset
|
86 (defvar display-time-server-down-time nil |
e277328474cc
(display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents:
4014
diff
changeset
|
87 "Time when mail file's file system was recorded to be down. |
e277328474cc
(display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents:
4014
diff
changeset
|
88 If that file system seems to be up, the value is nil.") |
e277328474cc
(display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents:
4014
diff
changeset
|
89 |
256 | 90 ;;;###autoload |
104 | 91 (defun display-time () |
15964
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
92 "Enable display of time, load level, and mail flag in mode lines. |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
93 This display updates automatically every minute. |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
94 If `display-time-day-and-date' is non-nil, the current day and date |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
95 are displayed as well. |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
96 This runs the normal hook `display-time-hook' after each update." |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
97 (interactive) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
98 (display-time-mode 1)) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
99 |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
100 ;;;###autoload |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
101 (defun display-time-mode (arg) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
102 "Toggle display of time, load level, and mail flag in mode lines. |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
103 With a numeric arg, enable this display if arg is positive. |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
104 |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
105 When this display is enabled, it updates automatically every minute. |
104 | 106 If `display-time-day-and-date' is non-nil, the current day and date |
107 are displayed as well. | |
15964
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
108 This runs the normal hook `display-time-hook' after each update." |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
109 (interactive "P") |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
110 (let ((on (if (null arg) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
111 (not display-time-timer) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
112 (> (prefix-numeric-value arg) 0)))) |
20583
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
113 (setq display-time-mode on) |
15964
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
114 (and display-time-timer (cancel-timer display-time-timer)) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
115 (setq display-time-timer nil) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
116 (setq display-time-string "") |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
117 (or global-mode-string (setq global-mode-string '(""))) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
118 (if on |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
119 (progn |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
120 (or (memq 'display-time-string global-mode-string) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
121 (setq global-mode-string |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
122 (append global-mode-string '(display-time-string)))) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
123 ;; Set up the time timer. |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
124 (setq display-time-timer |
16084
c477472563dd
(display-time): Use new run-at-time functionality to
Paul Eggert <eggert@twinsun.com>
parents:
15964
diff
changeset
|
125 (run-at-time t display-time-interval |
c477472563dd
(display-time): Use new run-at-time functionality to
Paul Eggert <eggert@twinsun.com>
parents:
15964
diff
changeset
|
126 'display-time-event-handler)) |
15964
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
127 ;; Make the time appear right away. |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
128 (display-time-update) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
129 ;; When you get new mail, clear "Mail" from the mode line. |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
130 (add-hook 'rmail-after-get-new-mail-hook |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
131 'display-time-event-handler)) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
132 (remove-hook 'rmail-after-get-new-mail-hook |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
133 'display-time-event-handler)))) |
0e6def53a74f
(display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
15749
diff
changeset
|
134 |
28797
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
135 (defcustom display-time-mail-face 'mode-line |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
136 "Face to use for `display-time-mail-string'. |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
137 If `display-time-use-mail-icon' is non-nil, the image's background |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
138 colour is the background of this face. Set this to a face other than |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
139 `mode-line' to make the mail indicator stand out on a suitable |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
140 display." |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
141 :group 'faces |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
142 :group 'display-time |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
143 :type 'face) |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
144 |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
145 (defvar display-time-mail-icon |
28884
5f062d58a68a
(display-time-mail-icon): Use `:ascent center'.
Gerd Moellmann <gerd@gnu.org>
parents:
28826
diff
changeset
|
146 (find-image '((:type xbm :file "letter.xbm" :ascent center))) |
28826 | 147 "Image specification to offer as the mail indicator on a graphic |
28797
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
148 display. See `display-time-use-mail-icon' and |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
149 `display-time-mail-face'.") |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
150 |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
151 (defcustom display-time-use-mail-icon nil |
28826 | 152 "Non-nil means use an icon as the mail indicator on a graphic display. |
28797
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
153 Otherwise use the string \"Mail\". The icon may consume less of the |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
154 mode line. It is specified by `display-time-mail-icon'." |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
155 :group 'display-time |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
156 :type 'boolean) |
104 | 157 |
17697 | 158 (defcustom display-time-format nil |
16530
08d4cb2b9754
(display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16084
diff
changeset
|
159 "*A string specifying the format for displaying the time in the mode line. |
08d4cb2b9754
(display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16084
diff
changeset
|
160 See the function `format-time-string' for an explanation of |
17644
d73425ee186b
(display-time-string-forms): Test display-time-day-and-date
Richard M. Stallman <rms@gnu.org>
parents:
16715
diff
changeset
|
161 how to write this string. If this is nil, the defaults |
17697 | 162 depend on `display-time-day-and-date' and `display-time-24hr-format'." |
163 :type '(choice (const :tag "Default" nil) | |
164 string) | |
165 :group 'display-time) | |
16530
08d4cb2b9754
(display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16084
diff
changeset
|
166 |
17697 | 167 (defcustom display-time-string-forms |
28797
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
168 '((if (and (not display-time-format) display-time-day-and-date) |
17644
d73425ee186b
(display-time-string-forms): Test display-time-day-and-date
Richard M. Stallman <rms@gnu.org>
parents:
16715
diff
changeset
|
169 (format-time-string "%a %b %e " now) |
d73425ee186b
(display-time-string-forms): Test display-time-day-and-date
Richard M. Stallman <rms@gnu.org>
parents:
16715
diff
changeset
|
170 "") |
d73425ee186b
(display-time-string-forms): Test display-time-day-and-date
Richard M. Stallman <rms@gnu.org>
parents:
16715
diff
changeset
|
171 (format-time-string (or display-time-format |
18566
496848617eb4
(display-time-string-forms): Use %M, not %m.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
172 (if display-time-24hr-format "%H:%M" "%-I:%M%p")) |
17644
d73425ee186b
(display-time-string-forms): Test display-time-day-and-date
Richard M. Stallman <rms@gnu.org>
parents:
16715
diff
changeset
|
173 now) |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
174 load |
28797
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
175 (if mail |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
176 ;; Build the string every time to act on customization. |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
177 (concat " " |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
178 (propertize |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
179 "Mail" |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
180 'display `(when (and display-time-use-mail-icon |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
181 (display-graphic-p)) |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
182 ,@display-time-mail-icon |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
183 ,@(list :background (face-attribute |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
184 display-time-mail-face |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
185 :background))) |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
186 'help-echo "mouse-2: Read mail" |
335a95fe243d
(display-time-mail-face, display-time-use-mail-icon):
Dave Love <fx@gnu.org>
parents:
27964
diff
changeset
|
187 'local-map (make-mode-line-mouse2-map read-mail-command))) |
27239
c681a4318a92
(display-time-string-forms): Make the Mail string active.
Dave Love <fx@gnu.org>
parents:
25825
diff
changeset
|
188 "")) |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
189 "*A list of expressions governing display of the time in the mode line. |
16530
08d4cb2b9754
(display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16084
diff
changeset
|
190 For most purposes, you can control the time format using `display-time-format' |
08d4cb2b9754
(display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16084
diff
changeset
|
191 which is a more standard interface. |
08d4cb2b9754
(display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16084
diff
changeset
|
192 |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
193 This expression is a list of expressions that can involve the keywords |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
194 `load', `day', `month', and `year', `12-hours', `24-hours', `minutes', |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
195 `seconds', all numbers in string form, and `monthname', `dayname', `am-pm', |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
196 and `time-zone' all alphabetic strings, and `mail' a true/nil value. |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
197 |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
198 For example, the form |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
199 |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
200 '((substring year -2) \"/\" month \"/\" day |
10317
dad32dba58bf
(display-time-string-forms): Fix doc string syntax error.
Richard M. Stallman <rms@gnu.org>
parents:
9581
diff
changeset
|
201 \" \" 24-hours \":\" minutes \":\" seconds |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
202 (if time-zone \" (\") time-zone (if time-zone \")\") |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
203 (if mail \" Mail\" \"\")) |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
204 |
17697 | 205 would give mode line times like `94/12/30 21:07:48 (UTC)'." |
206 :type 'sexp | |
207 :group 'display-time) | |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
208 |
14471
c1154020b9c3
(display-time): Rewrite to use built-in timers.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
209 (defun display-time-event-handler () |
14638
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
210 (display-time-update) |
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
211 ;; Do redisplay right now, if no input pending. |
16673
932451713b13
(display-time-event-handler): If Don't run the timer
Richard M. Stallman <rms@gnu.org>
parents:
16530
diff
changeset
|
212 (sit-for 0) |
16715
401e38b9650c
(display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
16704
diff
changeset
|
213 (let* ((current (current-time)) |
401e38b9650c
(display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
16704
diff
changeset
|
214 (timer display-time-timer) |
401e38b9650c
(display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
16704
diff
changeset
|
215 ;; Compute the time when this timer will run again, next. |
401e38b9650c
(display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
16704
diff
changeset
|
216 (next-time (timer-relative-time |
401e38b9650c
(display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
16704
diff
changeset
|
217 (list (aref timer 1) (aref timer 2) (aref timer 3)) |
401e38b9650c
(display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents:
16704
diff
changeset
|
218 (* 5 (aref timer 4)) 0))) |
16704
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
219 ;; If the activation time is far in the past, |
16673
932451713b13
(display-time-event-handler): If Don't run the timer
Richard M. Stallman <rms@gnu.org>
parents:
16530
diff
changeset
|
220 ;; skip executions until we reach a time in the future. |
932451713b13
(display-time-event-handler): If Don't run the timer
Richard M. Stallman <rms@gnu.org>
parents:
16530
diff
changeset
|
221 ;; This avoids a long pause if Emacs has been suspended for hours. |
16704
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
222 (or (> (nth 0 next-time) (nth 0 current)) |
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
223 (and (= (nth 0 next-time) (nth 0 current)) |
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
224 (> (nth 1 next-time) (nth 1 current))) |
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
225 (and (= (nth 0 next-time) (nth 0 current)) |
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
226 (= (nth 1 next-time) (nth 1 current)) |
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
227 (> (nth 2 next-time) (nth 2 current))) |
16673
932451713b13
(display-time-event-handler): If Don't run the timer
Richard M. Stallman <rms@gnu.org>
parents:
16530
diff
changeset
|
228 (progn |
932451713b13
(display-time-event-handler): If Don't run the timer
Richard M. Stallman <rms@gnu.org>
parents:
16530
diff
changeset
|
229 (timer-set-time timer (timer-next-integral-multiple-of-time |
16704
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
230 current display-time-interval) |
ab9da89a8283
(display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16673
diff
changeset
|
231 display-time-interval) |
16673
932451713b13
(display-time-event-handler): If Don't run the timer
Richard M. Stallman <rms@gnu.org>
parents:
16530
diff
changeset
|
232 (timer-activate timer))))) |
14638
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
233 |
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
234 ;; Update the display-time info for the mode line |
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
235 ;; but don't redisplay right now. This is used for |
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
236 ;; things like Rmail `g' that want to force an update |
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
237 ;; which can wait for the next redisplay. |
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
238 (defun display-time-update () |
12100 | 239 (let* ((now (current-time)) |
240 (time (current-time-string now)) | |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
241 (load (condition-case () |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
242 (if (zerop (car (load-average))) "" |
28826 | 243 ;; The load average number is mysterious, so |
27239
c681a4318a92
(display-time-string-forms): Make the Mail string active.
Dave Love <fx@gnu.org>
parents:
25825
diff
changeset
|
244 ;; propvide some help. |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
245 (let ((str (format " %03d" (car (load-average))))) |
27239
c681a4318a92
(display-time-string-forms): Make the Mail string active.
Dave Love <fx@gnu.org>
parents:
25825
diff
changeset
|
246 (propertize |
c681a4318a92
(display-time-string-forms): Make the Mail string active.
Dave Love <fx@gnu.org>
parents:
25825
diff
changeset
|
247 (concat (substring str 0 -2) "." (substring str -2)) |
27547
66e75f4824c8
(display-time-update): Change load-average help-echo.
Dave Love <fx@gnu.org>
parents:
27239
diff
changeset
|
248 'help-echo "System load average"))) |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
249 (error ""))) |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
250 (mail-spool-file (or display-time-mail-file |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
251 (getenv "MAIL") |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
252 (concat rmail-spool-directory |
8804
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
253 (user-login-name)))) |
9581
a035cc3716a1
(display-time-filter): Ignore mail-spool-file if not string.
Richard M. Stallman <rms@gnu.org>
parents:
8804
diff
changeset
|
254 (mail (and (stringp mail-spool-file) |
a035cc3716a1
(display-time-filter): Ignore mail-spool-file if not string.
Richard M. Stallman <rms@gnu.org>
parents:
8804
diff
changeset
|
255 (or (null display-time-server-down-time) |
8804
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
256 ;; If have been down for 20 min, try again. |
24693
7d78745d1195
(display-time-update): Allow for wrap-around when
Andrew Innes <andrewi@gnu.org>
parents:
24647
diff
changeset
|
257 (> (- (nth 1 now) display-time-server-down-time) |
7d78745d1195
(display-time-update): Allow for wrap-around when
Andrew Innes <andrewi@gnu.org>
parents:
24647
diff
changeset
|
258 1200) |
7d78745d1195
(display-time-update): Allow for wrap-around when
Andrew Innes <andrewi@gnu.org>
parents:
24647
diff
changeset
|
259 (and (< (nth 1 now) display-time-server-down-time) |
7d78745d1195
(display-time-update): Allow for wrap-around when
Andrew Innes <andrewi@gnu.org>
parents:
24647
diff
changeset
|
260 (> (- (nth 1 now) display-time-server-down-time) |
7d78745d1195
(display-time-update): Allow for wrap-around when
Andrew Innes <andrewi@gnu.org>
parents:
24647
diff
changeset
|
261 -64336))) |
8804
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
262 (let ((start-time (current-time))) |
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
263 (prog1 |
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
264 (display-time-file-nonempty-p mail-spool-file) |
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
265 (if (> (- (nth 1 (current-time)) (nth 1 start-time)) |
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
266 20) |
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
267 ;; Record that mail file is not accessible. |
19486
31fbf3a289c1
(display-time-hook): Minor doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18566
diff
changeset
|
268 (setq display-time-server-down-time |
8804
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
269 (nth 1 (current-time))) |
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
270 ;; Record that mail file is accessible. |
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
271 (setq display-time-server-down-time nil)))))) |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
272 (24-hours (substring time 11 13)) |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
273 (hour (string-to-int 24-hours)) |
8804
0e668dd3f120
(display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
8459
diff
changeset
|
274 (12-hours (int-to-string (1+ (% (+ hour 11) 12)))) |
8459
e1a2458245cb
(display-time-filter): pm starts at 12, not 13.
Richard M. Stallman <rms@gnu.org>
parents:
8404
diff
changeset
|
275 (am-pm (if (>= hour 12) "pm" "am")) |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
276 (minutes (substring time 14 16)) |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
277 (seconds (substring time 17 19)) |
12100 | 278 (time-zone (car (cdr (current-time-zone now)))) |
8404
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
279 (day (substring time 8 10)) |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
280 (year (substring time 20 24)) |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
281 (monthname (substring time 4 7)) |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
282 (month |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
283 (cdr |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
284 (assoc |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
285 monthname |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
286 '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4") |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
287 ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8") |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
288 ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12"))))) |
49ffb0b7fd22
(display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
289 (dayname (substring time 0 3))) |
104 | 290 (setq display-time-string |
12440
5f4248eb4bdd
(display-time-filter): Move run-hooks inside let.
Richard M. Stallman <rms@gnu.org>
parents:
12100
diff
changeset
|
291 (mapconcat 'eval display-time-string-forms "")) |
5f4248eb4bdd
(display-time-filter): Move run-hooks inside let.
Richard M. Stallman <rms@gnu.org>
parents:
12100
diff
changeset
|
292 ;; This is inside the let binding, but we are not going to document |
5f4248eb4bdd
(display-time-filter): Move run-hooks inside let.
Richard M. Stallman <rms@gnu.org>
parents:
12100
diff
changeset
|
293 ;; what variables are available. |
5f4248eb4bdd
(display-time-filter): Move run-hooks inside let.
Richard M. Stallman <rms@gnu.org>
parents:
12100
diff
changeset
|
294 (run-hooks 'display-time-hook)) |
14638
46556543f4e6
(display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents:
14471
diff
changeset
|
295 (force-mode-line-update)) |
256 | 296 |
297 (defun display-time-file-nonempty-p (file) | |
5463
e277328474cc
(display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents:
4014
diff
changeset
|
298 (and (file-exists-p file) |
e277328474cc
(display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents:
4014
diff
changeset
|
299 (< 0 (nth 7 (file-attributes (file-chase-links file)))))) |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
387
diff
changeset
|
300 |
20583
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
301 (if display-time-mode |
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
302 (display-time-mode t)) |
c2510bf630e4
(display-time-mode): Set the variable display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents:
19486
diff
changeset
|
303 |
18383 | 304 (provide 'time) |
305 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
387
diff
changeset
|
306 ;;; time.el ends here |