Mercurial > emacs
annotate lisp/time.el @ 81573:d5640ed7c397
(math-bignum-digit-length,math-bignum-digit-size,math-small-integer-size):
New constants.
(math-normalize,math-bignum-big,math-make-float,math-div10-bignum)
(math-scale-left,math-scale-left-bignum,math-scale-right)
(math-scale-right-bignum,math-scale-rounding,math-add,math-add-bignum)
(math-sub-bignum,math-sub,math-mul,math-mul-bignum,math-mul-bignum-digit)
(math-idivmod,math-quotient,math-div-bignum,math-div-bignum-digit)
(math-div-bignum-part,math-format-bignum-decimal,math-read-bignum):
Use math-bignum-digit-length, math-bignum-digit-size and
math-small-integer-size.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Sat, 23 Jun 2007 04:05:29 +0000 |
parents | 28206c0a5ce2 |
children | 9355f9b7bbff 31beec9ee600 |
rev | line source |
---|---|
50395 | 1 ;;; time.el --- display time, load and mail indicator in mode line of Emacs -*-coding: utf-8 -*- |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
2 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1996, 2000, 2001, 2002, |
75347 | 4 ;; 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
5 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
6 ;; Maintainer: FSF |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
7 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
9 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
13 ;; any later version. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
14 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
18 ;; GNU General Public License for more details. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
19 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64091 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
24 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
25 ;;; Commentary: |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
26 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
27 ;; Facilities to display current time/date and a new-mail indicator |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
28 ;; in the Emacs mode line. The single entry point is `display-time'. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
29 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
30 ;;; Code: |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
31 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
32 (defgroup display-time nil |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
33 "Display time and load in mode line of Emacs." |
72878
9aa76be5e74c
(display-time): Group mode-line instead of modeline.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
34 :group 'mode-line |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
35 :group 'mail) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
36 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
37 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
38 (defcustom display-time-mail-file nil |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
39 "*File name of mail inbox file, for indicating existence of new mail. |
77721
28206c0a5ce2
(display-time-mail-file): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
77715
diff
changeset
|
40 Non-nil and not a string means don't check for mail; nil means use |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
41 default, which is system-dependent, and is the same as used by Rmail." |
47486
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
42 :type '(choice (const :tag "None" none) |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
43 (const :tag "Default" nil) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
44 (file :format "%v")) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
45 :group 'display-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
46 |
42998
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
47 (defcustom display-time-mail-directory nil |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
48 "*Name of mail inbox directory, for indicating existence of new mail. |
45041
cbfb6a5db0be
(display-time-mail-directory, display-time-mail-function): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
42998
diff
changeset
|
49 Any nonempty regular file in the directory is regarded as newly arrived mail. |
cbfb6a5db0be
(display-time-mail-directory, display-time-mail-function): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
42998
diff
changeset
|
50 If nil, do not check a directory for arriving mail." |
42998
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
51 :type '(choice (const :tag "None" nil) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
52 (directory :format "%v")) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
53 :group 'display-time) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
54 |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
55 (defcustom display-time-mail-function nil |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
56 "*Function to call, for indicating existence of new mail. |
45041
cbfb6a5db0be
(display-time-mail-directory, display-time-mail-function): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
42998
diff
changeset
|
57 If nil, that means use the default method: check that the file |
cbfb6a5db0be
(display-time-mail-directory, display-time-mail-function): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
42998
diff
changeset
|
58 specified by `display-time-mail-file' is nonempty or that the |
cbfb6a5db0be
(display-time-mail-directory, display-time-mail-function): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
42998
diff
changeset
|
59 directory `display-time-mail-directory' contains nonempty files." |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
60 :type '(choice (const :tag "Default" nil) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
61 (function)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
62 :group 'display-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
63 |
42261
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
64 (defcustom display-time-default-load-average 0 |
50395 | 65 "*Which load average value will be shown in the mode line. |
42261
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
66 Almost every system can provide values of load for past 1 minute, past 5 or |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
67 past 15 minutes. The default is to display 1 minute load average." |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
68 :type '(choice (const :tag "1 minute load" 0) |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
69 (const :tag "5 minutes load" 1) |
47486
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
70 (const :tag "15 minutes load" 2) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
71 (const :tag "None" nil)) |
42261
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
72 :group 'display-time) |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
73 |
47486
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
74 (defvar display-time-load-average nil |
50395 | 75 "Load average currently being shown in mode line.") |
42261
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
76 |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
77 (defcustom display-time-load-average-threshold 0.1 |
42494
35eeafd85667
(display-time-load-average-threshold): Fix defcustom (add type and group).
Pavel Janík <Pavel@Janik.cz>
parents:
42261
diff
changeset
|
78 "*Load-average values below this value won't be shown in the mode line." |
35eeafd85667
(display-time-load-average-threshold): Fix defcustom (add type and group).
Pavel Janík <Pavel@Janik.cz>
parents:
42261
diff
changeset
|
79 :type 'number |
35eeafd85667
(display-time-load-average-threshold): Fix defcustom (add type and group).
Pavel Janík <Pavel@Janik.cz>
parents:
42261
diff
changeset
|
80 :group 'display-time) |
42261
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
81 |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
82 ;;;###autoload |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
83 (defcustom display-time-day-and-date nil "\ |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
84 *Non-nil means \\[display-time] should display day and date as well as time." |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
85 :type 'boolean |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
86 :group 'display-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
87 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
88 (defvar display-time-timer nil) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
89 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
90 (defcustom display-time-interval 60 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
91 "*Seconds between updates of time in the mode line." |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
92 :type 'integer |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
93 :group 'display-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
94 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
95 (defcustom display-time-24hr-format nil |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
96 "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. |
77715
5ccb0e885118
(display-time-24hr-format): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
97 A value of nil means 1 <= hh <= 12, and an AM/PM suffix is used." |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
98 :type 'boolean |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
99 :group 'display-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
100 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
101 (defvar display-time-string nil) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
102 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
103 (defcustom display-time-hook nil |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
104 "*List of functions to be called when the time is updated on the mode line." |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
105 :type 'hook |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
106 :group 'display-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
107 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
108 (defvar display-time-server-down-time nil |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
109 "Time when mail file's file system was recorded to be down. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
110 If that file system seems to be up, the value is nil.") |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
111 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
112 ;;;###autoload |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
113 (defun display-time () |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
114 "Enable display of time, load level, and mail flag in mode lines. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
115 This display updates automatically every minute. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
116 If `display-time-day-and-date' is non-nil, the current day and date |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
117 are displayed as well. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
118 This runs the normal hook `display-time-hook' after each update." |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
119 (interactive) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
120 (display-time-mode 1)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
121 |
50395 | 122 ;; This business used to be simpler when all mode lines had the same |
123 ;; face and the image could just be pbm. Now we try to rely on an xpm | |
124 ;; image with a transparent background. Otherwise, set the background | |
125 ;; for pbm. | |
126 | |
127 (defcustom display-time-mail-face nil | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
128 "Face to use for `display-time-mail-string'. |
50395 | 129 If `display-time-use-mail-icon' is non-nil, the image's |
63261
fbdbc34f3665
(display-time-mail-face): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62778
diff
changeset
|
130 background color is the background of this face. Set this to |
fbdbc34f3665
(display-time-mail-face): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62778
diff
changeset
|
131 make the mail indicator stand out on a color display." |
68217
7fad4c175274
(display-time-mail-face): Replace :group `faces' with `mode-line-faces'.
Juri Linkov <juri@jurta.org>
parents:
64903
diff
changeset
|
132 :group 'mode-line-faces |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
133 :group 'display-time |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
54525
diff
changeset
|
134 :version "22.1" |
50395 | 135 :type '(choice (const :tag "None" nil) face)) |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
136 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
137 (defvar display-time-mail-icon |
42998
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
138 (find-image '((:type xpm :file "letter.xpm" :ascent center) |
50395 | 139 (:type pbm :file "letter.pbm" :ascent center))) |
140 "Image specification to offer as the mail indicator on a graphic display. | |
141 See `display-time-use-mail-icon' and `display-time-mail-face'.") | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
142 |
50395 | 143 ;; Fixme: Default to icon on graphical display? |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
144 (defcustom display-time-use-mail-icon nil |
64903
7d23835637c8
(display-time-use-mail-icon, display-time-format)
Luc Teirlinck <teirllm@auburn.edu>
parents:
64762
diff
changeset
|
145 "Non-nil means use an icon as mail indicator on a graphic display. |
50395 | 146 Otherwise use `display-time-mail-string'. The icon may consume less |
147 of the mode line. It is specified by `display-time-mail-icon'." | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
148 :group 'display-time |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
149 :type 'boolean) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
150 |
50395 | 151 ;; Fixme: maybe default to the character if we can display Unicode. |
152 (defcustom display-time-mail-string "Mail" | |
153 "String to use as the mail indicator in `display-time-string-forms'. | |
154 This can use the Unicode letter character if you can display it." | |
155 :group 'display-time | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
54525
diff
changeset
|
156 :version "22.1" |
50395 | 157 :type '(choice (const "Mail") |
158 ;; Use :tag here because the Lucid menu won't display | |
159 ;; multibyte text. | |
160 (const :tag "Unicode letter character" "✉") | |
161 string)) | |
162 | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
163 (defcustom display-time-format nil |
64903
7d23835637c8
(display-time-use-mail-icon, display-time-format)
Luc Teirlinck <teirllm@auburn.edu>
parents:
64762
diff
changeset
|
164 "*String specifying format for displaying the time in the mode line. |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
165 See the function `format-time-string' for an explanation of |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
166 how to write this string. If this is nil, the defaults |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
167 depend on `display-time-day-and-date' and `display-time-24hr-format'." |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
168 :type '(choice (const :tag "Default" nil) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
169 string) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
170 :group 'display-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
171 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
172 (defcustom display-time-string-forms |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
173 '((if (and (not display-time-format) display-time-day-and-date) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
174 (format-time-string "%a %b %e " now) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
175 "") |
54434
de3c77f25914
(display-time-string-forms): Add help-echo with date on time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
176 (propertize |
de3c77f25914
(display-time-string-forms): Add help-echo with date on time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
177 (format-time-string (or display-time-format |
de3c77f25914
(display-time-string-forms): Add help-echo with date on time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
178 (if display-time-24hr-format "%H:%M" "%-I:%M%p")) |
de3c77f25914
(display-time-string-forms): Add help-echo with date on time.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
179 now) |
54525
b928269daf24
(display-time-string-forms): Fix help-echo date format.
Juri Linkov <juri@jurta.org>
parents:
54434
diff
changeset
|
180 'help-echo (format-time-string "%a %b %e, %Y" now)) |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
181 load |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
182 (if mail |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
183 ;; Build the string every time to act on customization. |
50395 | 184 ;; :set-after doesn't help for `customize-option'. I think it |
185 ;; should. | |
186 (concat | |
187 " " | |
188 (propertize | |
189 display-time-mail-string | |
190 'display `(when (and display-time-use-mail-icon | |
191 (display-graphic-p)) | |
192 ,@display-time-mail-icon | |
193 ,@(if (and display-time-mail-face | |
194 (memq (plist-get (cdr display-time-mail-icon) | |
195 :type) | |
196 '(pbm xbm))) | |
197 (let ((bg (face-attribute display-time-mail-face | |
198 :background))) | |
199 (if (stringp bg) | |
200 (list :background bg))))) | |
201 'face display-time-mail-face | |
202 'help-echo "You have new mail; mouse-2: Read mail" | |
62778
75fa29e46766
(display-time-string-forms, display-time-update):
Luc Teirlinck <teirllm@auburn.edu>
parents:
62402
diff
changeset
|
203 'mouse-face 'mode-line-highlight |
50395 | 204 'local-map (make-mode-line-mouse-map 'mouse-2 |
205 read-mail-command))) | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
206 "")) |
64903
7d23835637c8
(display-time-use-mail-icon, display-time-format)
Luc Teirlinck <teirllm@auburn.edu>
parents:
64762
diff
changeset
|
207 "*List of expressions governing display of the time in the mode line. |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
208 For most purposes, you can control the time format using `display-time-format' |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
209 which is a more standard interface. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
210 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
211 This expression is a list of expressions that can involve the keywords |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
212 `load', `day', `month', and `year', `12-hours', `24-hours', `minutes', |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
213 `seconds', all numbers in string form, and `monthname', `dayname', `am-pm', |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
214 and `time-zone' all alphabetic strings, and `mail' a true/nil value. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
215 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
216 For example, the form |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
217 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
218 '((substring year -2) \"/\" month \"/\" day |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
219 \" \" 24-hours \":\" minutes \":\" seconds |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
220 (if time-zone \" (\") time-zone (if time-zone \")\") |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
221 (if mail \" Mail\" \"\")) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
222 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
223 would give mode line times like `94/12/30 21:07:48 (UTC)'." |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
224 :type 'sexp |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
225 :group 'display-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
226 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
227 (defun display-time-event-handler () |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
228 (display-time-update) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
229 ;; Do redisplay right now, if no input pending. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
230 (sit-for 0) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
231 (let* ((current (current-time)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
232 (timer display-time-timer) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
233 ;; Compute the time when this timer will run again, next. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
234 (next-time (timer-relative-time |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
235 (list (aref timer 1) (aref timer 2) (aref timer 3)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
236 (* 5 (aref timer 4)) 0))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
237 ;; If the activation time is far in the past, |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
238 ;; skip executions until we reach a time in the future. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
239 ;; This avoids a long pause if Emacs has been suspended for hours. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
240 (or (> (nth 0 next-time) (nth 0 current)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
241 (and (= (nth 0 next-time) (nth 0 current)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
242 (> (nth 1 next-time) (nth 1 current))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
243 (and (= (nth 0 next-time) (nth 0 current)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
244 (= (nth 1 next-time) (nth 1 current)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
245 (> (nth 2 next-time) (nth 2 current))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
246 (progn |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
247 (timer-set-time timer (timer-next-integral-multiple-of-time |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
248 current display-time-interval) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
249 display-time-interval) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
250 (timer-activate timer))))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
251 |
42261
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
252 (defun display-time-next-load-average () |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
253 (interactive) |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
254 (if (= 3 (setq display-time-load-average (1+ display-time-load-average))) |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
255 (setq display-time-load-average 0)) |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
256 (display-time-update) |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
257 (sit-for 0)) |
4f42109edd02
(display-time-load-average-threshold): New variable.
Pavel Janík <Pavel@Janik.cz>
parents:
38759
diff
changeset
|
258 |
42998
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
259 (defun display-time-mail-check-directory () |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
260 (let ((mail-files (directory-files display-time-mail-directory t)) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
261 (size 0)) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
262 (while (and mail-files (= size 0)) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
263 ;; Count size of regular files only. |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
264 (setq size (+ size (or (and (file-regular-p (car mail-files)) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
265 (nth 7 (file-attributes (car mail-files)))) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
266 0))) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
267 (setq mail-files (cdr mail-files))) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
268 (if (> size 0) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
269 size |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
270 nil))) |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
271 |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
272 (defun display-time-update () |
50395 | 273 "Update the display-time info for the mode line. |
274 However, don't redisplay right now. | |
275 | |
276 This is used for things like Rmail `g' that want to force an | |
277 update which can wait for the next redisplay." | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
278 (let* ((now (current-time)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
279 (time (current-time-string now)) |
47486
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
280 (load (if (null display-time-load-average) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
281 "" |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
282 (condition-case () |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
283 ;; Do not show values less than |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
284 ;; `display-time-load-average-threshold'. |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
285 (if (> (* display-time-load-average-threshold 100) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
286 (nth display-time-load-average (load-average))) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
287 "" |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
288 ;; The load average number is mysterious, so |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
289 ;; provide some help. |
50395 | 290 (let ((str (format " %03d" |
291 (nth display-time-load-average | |
292 (load-average))))) | |
47486
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
293 (propertize |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
294 (concat (substring str 0 -2) "." (substring str -2)) |
50395 | 295 'local-map (make-mode-line-mouse-map |
296 'mouse-2 'display-time-next-load-average) | |
62778
75fa29e46766
(display-time-string-forms, display-time-update):
Luc Teirlinck <teirllm@auburn.edu>
parents:
62402
diff
changeset
|
297 'mouse-face 'mode-line-highlight |
50395 | 298 'help-echo (concat |
299 "System load average for past " | |
300 (if (= 0 display-time-load-average) | |
301 "1 minute" | |
302 (if (= 1 display-time-load-average) | |
303 "5 minutes" | |
304 "15 minutes")) | |
305 "; mouse-2: next")))) | |
47486
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
306 (error "")))) |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
307 (mail-spool-file (or display-time-mail-file |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
308 (getenv "MAIL") |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
309 (concat rmail-spool-directory |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
310 (user-login-name)))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
311 (mail (or (and display-time-mail-function |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
312 (funcall display-time-mail-function)) |
42998
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
313 (and display-time-mail-directory |
144c91651228
(display-time-mail-directory): New option.
Pavel Janík <Pavel@Janik.cz>
parents:
42838
diff
changeset
|
314 (display-time-mail-check-directory)) |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
315 (and (stringp mail-spool-file) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
316 (or (null display-time-server-down-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
317 ;; If have been down for 20 min, try again. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
318 (> (- (nth 1 now) display-time-server-down-time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
319 1200) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
320 (and (< (nth 1 now) display-time-server-down-time) |
50395 | 321 (> (- (nth 1 now) |
322 display-time-server-down-time) | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
323 -64336))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
324 (let ((start-time (current-time))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
325 (prog1 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
326 (display-time-file-nonempty-p mail-spool-file) |
50395 | 327 (if (> (- (nth 1 (current-time)) |
328 (nth 1 start-time)) | |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
329 20) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
330 ;; Record that mail file is not accessible. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
331 (setq display-time-server-down-time |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
332 (nth 1 (current-time))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
333 ;; Record that mail file is accessible. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
334 (setq display-time-server-down-time nil))))))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
335 (24-hours (substring time 11 13)) |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
336 (hour (string-to-number 24-hours)) |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
337 (12-hours (int-to-string (1+ (% (+ hour 11) 12)))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
338 (am-pm (if (>= hour 12) "pm" "am")) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
339 (minutes (substring time 14 16)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
340 (seconds (substring time 17 19)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
341 (time-zone (car (cdr (current-time-zone now)))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
342 (day (substring time 8 10)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
343 (year (substring time 20 24)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
344 (monthname (substring time 4 7)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
345 (month |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
346 (cdr |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
347 (assoc |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
348 monthname |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
349 '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4") |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
350 ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8") |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
351 ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12"))))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
352 (dayname (substring time 0 3))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
353 (setq display-time-string |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
354 (mapconcat 'eval display-time-string-forms "")) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
355 ;; This is inside the let binding, but we are not going to document |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
356 ;; what variables are available. |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
357 (run-hooks 'display-time-hook)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
358 (force-mode-line-update)) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
359 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
360 (defun display-time-file-nonempty-p (file) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
361 (and (file-exists-p file) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
362 (< 0 (nth 7 (file-attributes (file-chase-links file)))))) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
363 |
31980
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
364 ;;;###autoload |
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
365 (define-minor-mode display-time-mode |
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
366 "Toggle display of time, load level, and mail flag in mode lines. |
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
367 With a numeric arg, enable this display if arg is positive. |
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
368 |
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
369 When this display is enabled, it updates automatically every minute. |
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
370 If `display-time-day-and-date' is non-nil, the current day and date |
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
371 are displayed as well. |
ceb42baae241
(display-time-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29706
diff
changeset
|
372 This runs the normal hook `display-time-hook' after each update." |
33197
5ddf69eeb2bb
(display-time-mode): Drop unneeded positional args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31980
diff
changeset
|
373 :global t :group 'display-time |
47486
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
374 (and display-time-timer (cancel-timer display-time-timer)) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
375 (setq display-time-timer nil) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
376 (setq display-time-string "") |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
377 (or global-mode-string (setq global-mode-string '(""))) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
378 (setq display-time-load-average display-time-default-load-average) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
379 (if display-time-mode |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
380 (progn |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
381 (or (memq 'display-time-string global-mode-string) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
382 (setq global-mode-string |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
383 (append global-mode-string '(display-time-string)))) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
384 ;; Set up the time timer. |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
385 (setq display-time-timer |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
386 (run-at-time t display-time-interval |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
387 'display-time-event-handler)) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
388 ;; Make the time appear right away. |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
389 (display-time-update) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
390 ;; When you get new mail, clear "Mail" from the mode line. |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
391 (add-hook 'rmail-after-get-new-mail-hook |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
392 'display-time-event-handler)) |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
393 (remove-hook 'rmail-after-get-new-mail-hook |
19084a962da7
(display-time-mode): Set display-time-load-average here.
Richard M. Stallman <rms@gnu.org>
parents:
45041
diff
changeset
|
394 'display-time-event-handler))) |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
395 |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
396 (provide 'time) |
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
397 |
52401 | 398 ;;; arch-tag: b9c1623f-b5cb-48e4-b650-482a4d23c5a6 |
29706
1030e638c8dd
Remove trailing ^M that prevent CVS-merging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29693
diff
changeset
|
399 ;;; time.el ends here |