annotate lisp/time.el @ 19860:c17fd465ea95 libc-970911 libc-970912 libc-970913 libc-970914 libc-970915 libc-970916 libc-970917 libc-970918 libc-970919 libc-970920 libc-970921 libc-970922 libc-970923 libc-970924 libc-970925 libc-970926 libc-970927 libc-970928 libc-970929 libc-970930 libc-971001 libc-971018 libc-971019 libc-971020 libc-971021 libc-971022 libc-971023 libc-971024 libc-971025 libc-971026 libc-971027 libc-971028 libc-971029 libc-971030 libc-971031 libc-971101 libc-971102 libc-971103 libc-971104 libc-971105 libc-971106 libc-971107 libc-971108 libc-971109 libc-971110 libc-971111 libc-971112 libc-971113 libc-971114 libc-971115 libc-971116 libc-971117 libc-971118 libc-971120 libc-971121 libc-971122 libc-971123 libc-971124 libc-971125 libc-971126 libc-971127 libc-971128 libc-971129 libc-971130 libc-971201 libc-971203 libc-971204 libc-971205 libc-971206 libc-971207 libc-971208 libc-971209 libc-971210 libc-971211 libc-971212 libc-971213 libc-971214 libc-971217 libc-971218 libc-971219 libc-971220 libc-971221 libc-971222 libc-971223 libc-971224 libc-971225 libc-971226 libc-971227 libc-971228 libc-971229 libc-971230 libc-971231 libc-980103 libc-980104 libc-980105 libc-980106 libc-980107 libc-980108 libc-980109 libc-980110 libc-980111 libc-980112 libc-980114 libc-980115 libc-980116 libc-980117 libc-980118 libc-980119 libc-980120 libc-980121 libc-980122 libc-980123 libc-980124 libc-980125 libc-980126 libc-980127 libc-980128

typos.
author Jeff Law <law@redhat.com>
date Wed, 10 Sep 1997 21:16:20 +0000
parents 31fbf3a289c1
children c2510bf630e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 387
diff changeset
1 ;;; time.el --- display time and load in mode line of Emacs.
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 387
diff changeset
2
14734
20f4c4a078b2 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 14700
diff changeset
3 ;; Copyright (C) 1985, 86, 87, 93, 94, 1996 Free Software Foundation, Inc.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 657
diff changeset
5 ;; Maintainer: FSF
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; any later version.
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13747
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13747
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13747
diff changeset
22 ;; Boston, MA 02111-1307, USA.
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13747
diff changeset
26 ;; Facilities to display current time/date and a new-mail indicator
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13747
diff changeset
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
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
31 (defgroup display-time nil
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
32 "Display time and load in mode line of Emacs."
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
33 :group 'modeline
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
34 :group 'mail)
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
35
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
36
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
37 (defcustom display-time-mail-file nil
132
0cbdae7c532f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 104
diff changeset
38 "*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
39 Non-nil and not a string means don't check for mail. nil means use
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
40 default, which is system-dependent, and is the same as used by Rmail."
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
41 :type '(choice (const :tag "Default" nil)
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
42 (file :format "%v"))
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
43 :group 'display-time)
132
0cbdae7c532f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 104
diff changeset
44
268
2dd411fe2f72 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 262
diff changeset
45 ;;;###autoload
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
46 (defcustom display-time-day-and-date nil "\
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
47 *Non-nil means \\[display-time] should display day and date as well as time."
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
48 :type 'boolean
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
49 :group 'display-time)
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 132
diff changeset
50
14471
c1154020b9c3 (display-time): Rewrite to use built-in timers.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
51 (defvar display-time-timer nil)
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
53 (defcustom display-time-interval 60
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
54 "*Seconds between updates of time in the mode line."
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
55 :type 'integer
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
56 :group 'display-time)
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
58 (defcustom display-time-24hr-format nil
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
59 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23.
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
60 Nil means 1 <= hh <= 12, and an AM/PM suffix is used."
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
61 :type 'boolean
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
62 :group 'display-time)
387
8f76cc1e1067 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 271
diff changeset
63
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (defvar display-time-string nil)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
66 (defcustom display-time-hook nil
19486
31fbf3a289c1 (display-time-hook): Minor doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18566
diff changeset
67 "*List of functions to be called when the time is updated on the mode line."
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
68 :type 'hook
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
69 :group 'display-time)
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
5463
e277328474cc (display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents: 4014
diff changeset
71 (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
72 "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
73 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
74
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 132
diff changeset
75 ;;;###autoload
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (defun display-time ()
15964
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
77 "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
78 This display updates automatically every minute.
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
79 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
80 are displayed as well.
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
81 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
82 (interactive)
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
83 (display-time-mode 1))
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
84
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
85 ;;;###autoload
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
86 (defun display-time-mode (arg)
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
87 "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
88 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
89
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
90 When this display is enabled, it updates automatically every minute.
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 If `display-time-day-and-date' is non-nil, the current day and date
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 are displayed as well.
15964
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
93 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
94 (interactive "P")
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
95 (let ((on (if (null arg)
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
96 (not display-time-timer)
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
97 (> (prefix-numeric-value arg) 0))))
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
98 (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
99 (setq display-time-timer nil)
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
100 (setq display-time-string "")
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
101 (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
102 (if on
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
103 (progn
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
104 (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
105 (setq global-mode-string
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
106 (append global-mode-string '(display-time-string))))
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
107 ;; Set up the time timer.
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
108 (setq display-time-timer
16084
c477472563dd (display-time): Use new run-at-time functionality to
Paul Eggert <eggert@twinsun.com>
parents: 15964
diff changeset
109 (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
110 'display-time-event-handler))
15964
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
111 ;; Make the time appear right away.
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
112 (display-time-update)
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
113 ;; 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
114 (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
115 'display-time-event-handler))
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
116 (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
117 'display-time-event-handler))))
0e6def53a74f (display-time): Call display-time-mode.
Richard M. Stallman <rms@gnu.org>
parents: 15749
diff changeset
118
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
120 (defcustom display-time-format nil
16530
08d4cb2b9754 (display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16084
diff changeset
121 "*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
122 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
123 how to write this string. If this is nil, the defaults
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
124 depend on `display-time-day-and-date' and `display-time-24hr-format'."
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
125 :type '(choice (const :tag "Default" nil)
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
126 string)
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
127 :group 'display-time)
16530
08d4cb2b9754 (display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16084
diff changeset
128
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
129 (defcustom display-time-string-forms
17644
d73425ee186b (display-time-string-forms): Test display-time-day-and-date
Richard M. Stallman <rms@gnu.org>
parents: 16715
diff changeset
130 '((if (and (not display-time-format) display-time-day-and-date)
d73425ee186b (display-time-string-forms): Test display-time-day-and-date
Richard M. Stallman <rms@gnu.org>
parents: 16715
diff changeset
131 (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
132 "")
d73425ee186b (display-time-string-forms): Test display-time-day-and-date
Richard M. Stallman <rms@gnu.org>
parents: 16715
diff changeset
133 (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
134 (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
135 now)
8404
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
136 load
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
137 (if mail " Mail" ""))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
138 "*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
139 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
140 which is a more standard interface.
08d4cb2b9754 (display-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16084
diff changeset
141
8404
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
142 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
143 `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
144 `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
145 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
146
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
147 For example, the form
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
148
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
149 '((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
150 \" \" 24-hours \":\" minutes \":\" seconds
8404
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
151 (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
152 (if mail \" Mail\" \"\"))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
153
17697
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
154 would give mode line times like `94/12/30 21:07:48 (UTC)'."
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
155 :type 'sexp
8ef3e5ff7ee2 Customize.
Richard M. Stallman <rms@gnu.org>
parents: 17644
diff changeset
156 :group 'display-time)
8404
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
157
14471
c1154020b9c3 (display-time): Rewrite to use built-in timers.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
158 (defun display-time-event-handler ()
14638
46556543f4e6 (display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents: 14471
diff changeset
159 (display-time-update)
46556543f4e6 (display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents: 14471
diff changeset
160 ;; 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
161 (sit-for 0)
16715
401e38b9650c (display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents: 16704
diff changeset
162 (let* ((current (current-time))
401e38b9650c (display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents: 16704
diff changeset
163 (timer display-time-timer)
401e38b9650c (display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents: 16704
diff changeset
164 ;; 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
165 (next-time (timer-relative-time
401e38b9650c (display-time-event-handler): Use let*.
Richard M. Stallman <rms@gnu.org>
parents: 16704
diff changeset
166 (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
167 (* 5 (aref timer 4)) 0)))
16704
ab9da89a8283 (display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 16673
diff changeset
168 ;; 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
169 ;; 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
170 ;; 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
171 (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
172 (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
173 (> (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
174 (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
175 (= (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
176 (> (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
177 (progn
932451713b13 (display-time-event-handler): If Don't run the timer
Richard M. Stallman <rms@gnu.org>
parents: 16530
diff changeset
178 (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
179 current display-time-interval)
ab9da89a8283 (display-time-event-handler): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 16673
diff changeset
180 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
181 (timer-activate timer)))))
14638
46556543f4e6 (display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents: 14471
diff changeset
182
46556543f4e6 (display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents: 14471
diff changeset
183 ;; 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
184 ;; 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
185 ;; 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
186 ;; 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
187 (defun display-time-update ()
12100
ad9b385814fc (display-time-filter):
Karl Heuer <kwzh@gnu.org>
parents: 11568
diff changeset
188 (let* ((now (current-time))
ad9b385814fc (display-time-filter):
Karl Heuer <kwzh@gnu.org>
parents: 11568
diff changeset
189 (time (current-time-string now))
8404
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
190 (load (condition-case ()
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
191 (if (zerop (car (load-average))) ""
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
192 (let ((str (format " %03d" (car (load-average)))))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
193 (concat (substring str 0 -2) "." (substring str -2))))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
194 (error "")))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
195 (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
196 (getenv "MAIL")
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
197 (concat rmail-spool-directory
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
198 (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
199 (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
200 (or (null display-time-server-down-time)
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
201 ;; If have been down for 20 min, try again.
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
202 (> (- (nth 1 (current-time))
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
203 display-time-server-down-time)
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
204 1200))
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
205 (let ((start-time (current-time)))
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
206 (prog1
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
207 (display-time-file-nonempty-p mail-spool-file)
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
208 (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
209 20)
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
210 ;; 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
211 (setq display-time-server-down-time
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
212 (nth 1 (current-time)))
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
213 ;; Record that mail file is accessible.
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
214 (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
215 (24-hours (substring time 11 13))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
216 (hour (string-to-int 24-hours))
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
217 (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
218 (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
219 (minutes (substring time 14 16))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
220 (seconds (substring time 17 19))
12100
ad9b385814fc (display-time-filter):
Karl Heuer <kwzh@gnu.org>
parents: 11568
diff changeset
221 (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
222 (day (substring time 8 10))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
223 (year (substring time 20 24))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
224 (monthname (substring time 4 7))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
225 (month
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
226 (cdr
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
227 (assoc
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
228 monthname
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
229 '(("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
230 ("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
231 ("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
232 (dayname (substring time 0 3)))
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (setq display-time-string
12440
5f4248eb4bdd (display-time-filter): Move run-hooks inside let.
Richard M. Stallman <rms@gnu.org>
parents: 12100
diff changeset
234 (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
235 ;; 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
236 ;; what variables are available.
5f4248eb4bdd (display-time-filter): Move run-hooks inside let.
Richard M. Stallman <rms@gnu.org>
parents: 12100
diff changeset
237 (run-hooks 'display-time-hook))
14638
46556543f4e6 (display-time-update): New subroutine broken out from
Karl Heuer <kwzh@gnu.org>
parents: 14471
diff changeset
238 (force-mode-line-update))
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 132
diff changeset
239
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 132
diff changeset
240 (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
241 (and (file-exists-p file)
e277328474cc (display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents: 4014
diff changeset
242 (< 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
243
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17697
diff changeset
244 (provide 'time)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17697
diff changeset
245
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 387
diff changeset
246 ;;; time.el ends here