annotate lisp/time.el @ 9731:2fbc8ef9ff44

(find-file-noselect): Call set-buffer-major-mode here.
author Karl Heuer <kwzh@gnu.org>
date Thu, 27 Oct 1994 22:34:21 +0000
parents a035cc3716a1
children dad32dba58bf
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
7300
cc7cd83ccf3f Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 7017
diff changeset
3 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994 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
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
2319
d98c49df2acd Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2293
diff changeset
23 ;;; Commentary:
d98c49df2acd Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2293
diff changeset
24
d98c49df2acd Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2293
diff changeset
25 ;;; Facilities to display current time/date and a new-mail indicator
d98c49df2acd Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2293
diff changeset
26 ;;; in the Emacs mode line. The single entry point is `display-time'.
d98c49df2acd Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2293
diff changeset
27
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 657
diff changeset
28 ;;; Code:
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
132
0cbdae7c532f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 104
diff changeset
30 (defvar display-time-mail-file nil
0cbdae7c532f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 104
diff changeset
31 "*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
32 Non-nil and not a string means don't check for mail. nil means use
a035cc3716a1 (display-time-filter): Ignore mail-spool-file if not string.
Richard M. Stallman <rms@gnu.org>
parents: 8804
diff changeset
33 default, which is system-dependent, and is the same as used by Rmail.")
132
0cbdae7c532f *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 104
diff changeset
34
268
2dd411fe2f72 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 262
diff changeset
35 ;;;###autoload
3167
e4bcdaa214b1 (display-time-day-and-date): Use defvar, not defconst.
Richard M. Stallman <rms@gnu.org>
parents: 2319
diff changeset
36 (defvar display-time-day-and-date nil "\
268
2dd411fe2f72 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 262
diff changeset
37 *Non-nil means \\[display-time] should display day and date as well as time.")
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 132
diff changeset
38
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (defvar display-time-process nil)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 (defvar display-time-interval 60
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 "*Seconds between updates of time in the mode line.")
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
387
8f76cc1e1067 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 271
diff changeset
44 (defvar display-time-24hr-format nil
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
45 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23.
387
8f76cc1e1067 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 271
diff changeset
46 Nil means 1 <= hh <= 12, and an AM/PM suffix is used.")
8f76cc1e1067 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 271
diff changeset
47
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (defvar display-time-string nil)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (defvar display-time-hook nil
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 "* List of functions to be called when the time is updated on the mode line.")
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
5463
e277328474cc (display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents: 4014
diff changeset
53 (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
54 "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
55 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
56
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 132
diff changeset
57 ;;;###autoload
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (defun display-time ()
2293
6c5e38aeb94b * time.el (display-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 841
diff changeset
59 "Display current time, load level, and mail flag in mode line of each buffer.
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 Updates automatically every minute.
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 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
62 are displayed as well.
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 After each update, `display-time-hook' is run with `run-hooks'."
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (interactive)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (let ((live (and display-time-process
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (eq (process-status display-time-process) 'run))))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (if (not live)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (progn
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (if display-time-process
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (delete-process display-time-process))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (or global-mode-string (setq global-mode-string '("")))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (or (memq 'display-time-string global-mode-string)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (setq global-mode-string
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (append global-mode-string '(display-time-string))))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (setq display-time-string "")
7017
6884e6e907c9 (display-time): Force use of pipe, not pty.
Richard M. Stallman <rms@gnu.org>
parents: 5909
diff changeset
76 ;; Using a pty is wasteful, and the separate session causes
6884e6e907c9 (display-time): Force use of pipe, not pty.
Richard M. Stallman <rms@gnu.org>
parents: 5909
diff changeset
77 ;; annoyance sometimes (some systems kill idle sessions).
6884e6e907c9 (display-time): Force use of pipe, not pty.
Richard M. Stallman <rms@gnu.org>
parents: 5909
diff changeset
78 (let ((process-connection-type nil))
6884e6e907c9 (display-time): Force use of pipe, not pty.
Richard M. Stallman <rms@gnu.org>
parents: 5909
diff changeset
79 (setq display-time-process
6884e6e907c9 (display-time): Force use of pipe, not pty.
Richard M. Stallman <rms@gnu.org>
parents: 5909
diff changeset
80 (start-process "display-time" nil
6884e6e907c9 (display-time): Force use of pipe, not pty.
Richard M. Stallman <rms@gnu.org>
parents: 5909
diff changeset
81 (expand-file-name "wakeup" exec-directory)
6884e6e907c9 (display-time): Force use of pipe, not pty.
Richard M. Stallman <rms@gnu.org>
parents: 5909
diff changeset
82 (int-to-string display-time-interval))))
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (process-kill-without-query display-time-process)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (set-process-sentinel display-time-process 'display-time-sentinel)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (set-process-filter display-time-process 'display-time-filter)))))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (defun display-time-sentinel (proc reason)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (or (eq (process-status proc) 'run)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (setq display-time-string ""))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; Force mode-line updates
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (save-excursion (set-buffer (other-buffer)))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (set-buffer-modified-p (buffer-modified-p))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (sit-for 0))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94
8404
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
95 (defvar display-time-string-forms
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
96 '((if display-time-day-and-date
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
97 (format "%s %s %s " dayname monthname day)
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
98 "")
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
99 (format "%s:%s%s"
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
100 (if display-time-24hr-format 24-hours 12-hours)
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
101 minutes
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
102 (if display-time-24hr-format "" am-pm))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
103 load
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
104 (if mail " Mail" ""))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
105 "*A list of expressions governing display of the time in the mode line.
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
106 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
107 `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
108 `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
109 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
110
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
111 For example, the form
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
112
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
113 '((substring year -2) \"/\" month \"/\" day
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
114 " " 24-hours \":\" minutes \":\" seconds
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
115 (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
116 (if mail \" Mail\" \"\"))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
117
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
118 would give mode line times like `94/12/30 21:07:48 (UTC)'.")
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
119
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (defun display-time-filter (proc string)
8404
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
121 (let* ((time (current-time-string))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
122 (load (condition-case ()
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
123 (if (zerop (car (load-average))) ""
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
124 (let ((str (format " %03d" (car (load-average)))))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
125 (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
126 (error "")))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
127 (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
128 (getenv "MAIL")
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
129 (concat rmail-spool-directory
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
130 (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
131 (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
132 (or (null display-time-server-down-time)
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
133 ;; 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
134 (> (- (nth 1 (current-time))
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
135 display-time-server-down-time)
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
136 1200))
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
137 (let ((start-time (current-time)))
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
138 (prog1
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
139 (display-time-file-nonempty-p mail-spool-file)
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
140 (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
141 20)
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
142 ;; Record that mail file is not accessible.
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
143 (setq display-time-server-down-time
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
144 (nth 1 (current-time)))
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
145 ;; Record that mail file is accessible.
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
146 (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
147 (24-hours (substring time 11 13))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
148 (hour (string-to-int 24-hours))
8804
0e668dd3f120 (display-time-24hr-format): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 8459
diff changeset
149 (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
150 (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
151 (minutes (substring time 14 16))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
152 (seconds (substring time 17 19))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
153 (time-zone (car (cdr (current-time-zone))))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
154 (day (substring time 8 10))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
155 (year (substring time 20 24))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
156 (monthname (substring time 4 7))
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
157 (month
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
158 (cdr
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
159 (assoc
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
160 monthname
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
161 '(("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
162 ("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
163 ("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
164 (dayname (substring time 0 3)))
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (setq display-time-string
8404
49ffb0b7fd22 (display-time-string-forms): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
166 (mapconcat 'eval display-time-string-forms "")))
104
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (run-hooks 'display-time-hook)
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 ;; Force redisplay of all buffers' mode lines to be considered.
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (save-excursion (set-buffer (other-buffer)))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (set-buffer-modified-p (buffer-modified-p))
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ;; Do redisplay right now, if no input pending.
b6fb5f9cb739 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (sit-for 0))
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 132
diff changeset
173
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 132
diff changeset
174 (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
175 (and (file-exists-p file)
e277328474cc (display-time-file-nonempty-p): Check existence here.
Richard M. Stallman <rms@gnu.org>
parents: 4014
diff changeset
176 (< 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
177
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 387
diff changeset
178 ;;; time.el ends here