Mercurial > emacs
annotate lisp/time-stamp.el @ 73057:76991373b070
Add Greek letters to math-variable-table properties of tex.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Fri, 22 Sep 2006 17:44:35 +0000 |
parents | d84cbfb84b06 |
children | f1bc46cb2d2d 2ecafc6d5db7 |
rev | line source |
---|---|
3854 | 1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs |
2 | |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 1989, 1993, 1994, 1995, 1997, 2000, 2001, 2002, 2003, |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65449
diff
changeset
|
4 ;; 2004, 2005, 2006 Free Software Foundation, Inc. |
14169 | 5 |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37083
diff
changeset
|
6 ;; This file is part of GNU Emacs. |
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37083
diff
changeset
|
7 |
69980
f347a837af60
(time-stamp-format, time-stamp-line-limit)
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
8 ;; Maintainer's Time-stamp: <2006-04-12 20:30:56 rms> |
39229
bf5f26157d70
Update Stephen Gildea's email address.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
9 ;; Maintainer: Stephen Gildea <gildea@stop.mail-abuse.org> |
3854 | 10 ;; Keywords: tools |
11 | |
45340 | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3854 | 13 ;; it under the terms of the GNU General Public License as published by |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
45341 | 17 ;; GNU Emacs is distributed in the hope that it will be useful, |
3854 | 18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64091 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
3854 | 26 |
27 ;;; Commentary: | |
28 | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
29 ;; A template in a file can be updated with a new time stamp when |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
30 ;; you save the file. For example: |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
31 ;; static char *ts = "sdmain.c Time-stamp: <2001-08-13 10:20:51 gildea>"; |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
32 ;; See the top of `time-stamp.el' for another example. |
3854 | 33 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
34 ;; To use time-stamping, add this line to your .emacs file: |
56074
7aab74a19427
(time-stamp): Recommend adding it to `before-save-hook', rather than
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
35 ;; (add-hook 'before-save-hook 'time-stamp) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
36 ;; Now any time-stamp templates in your files will be updated automatically. |
3854 | 37 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
38 ;; See the documentation for the functions `time-stamp' |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
39 ;; and `time-stamp-toggle-active' for details. |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
40 |
3854 | 41 ;;; Code: |
42 | |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
43 (defgroup time-stamp nil |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
44 "Maintain last change time stamps in files edited by Emacs." |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
45 :group 'data |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
46 :group 'extensions) |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
47 |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
48 (defcustom time-stamp-format "%:y-%02m-%02d %02H:%02M:%02S %u" |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
49 "*Format of the string inserted by \\[time-stamp]. |
16674
91590d8f74c3
(time-stamp-am-pm): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
16517
diff
changeset
|
50 The value may be a string or a list. Lists are supported only for |
91590d8f74c3
(time-stamp-am-pm): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
16517
diff
changeset
|
51 backward compatibility; see variable `time-stamp-old-format-warn'. |
13356 | 52 |
35627 | 53 A string is used verbatim except for character sequences beginning |
54 with %, as follows. The values of non-numeric formatted items depend | |
37083
15fc82d712ac
(time-stamp-format): Doc fix. From Paul Eggert <eggert@twinsun.com>.
Eli Zaretskii <eliz@gnu.org>
parents:
35695
diff
changeset
|
55 on the locale setting recorded in `system-time-locale' and |
15fc82d712ac
(time-stamp-format): Doc fix. From Paul Eggert <eggert@twinsun.com>.
Eli Zaretskii <eliz@gnu.org>
parents:
35695
diff
changeset
|
56 `locale-coding-system'. The examples here are for the default |
45138
6855d0e47c10
(time-stamp-format): Escape open parenthesis in column 0.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
39371
diff
changeset
|
57 \(`C') locale. |
16705
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
58 |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
59 %:a weekday name: `Monday'. %#A gives uppercase: `MONDAY' |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
60 %3a abbreviated weekday: `Mon'. %3A gives uppercase: `MON' |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
61 %:b month name: `January'. %#B gives uppercase: `JANUARY' |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
62 %3b abbreviated month: `Jan'. %3B gives uppercase: `JAN' |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
63 %02d day of month |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
64 %02H 24-hour clock hour |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
65 %02I 12-hour clock hour |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
66 %02m month number |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
67 %02M minute |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
68 %#p `am' or `pm'. %P gives uppercase: `AM' or `PM' |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
69 %02S seconds |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
70 %w day number of week, Sunday is 0 |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
71 %02y 2-digit year: `03' %:y 4-digit year: `2003' |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
72 %z time zone name: `est'. %Z gives uppercase: `EST' |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
73 |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
74 Non-date items: |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
75 %% a literal percent character: `%' |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
76 %f file name without directory %F gives absolute pathname |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
77 %s system name |
24266
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
78 %u user's login name %U user's full name |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
79 %h mail host name |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
80 |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
81 Decimal digits between the % and the type character specify the |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
82 field width. Strings are truncated on the right; years on the left. |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
83 A leading zero in the field width zero-fills a number. |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
84 |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
85 For example, to get the format used by the `date' command, |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
86 use \"%3a %3b %2d %02H:%02M:%02S %Z %:y\". |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
87 |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
88 In the future these formats will be aligned more with `format-time-string'. |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
89 Because of this transition, the default padding for numeric formats will |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
90 change in a future version. Therefore either a padding width should be |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
91 specified, or the : modifier should be used to explicitly request the |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
92 historical default." |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
93 :type 'string |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
94 :group 'time-stamp |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
95 :version "20.1") |
69980
f347a837af60
(time-stamp-format, time-stamp-line-limit)
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
96 ;;;###autoload(put 'time-stamp-format 'safe-local-variable 'stringp) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
97 |
19504
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
98 (defcustom time-stamp-active t |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
99 "*Non-nil to enable time-stamping of buffers by \\[time-stamp]. |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
100 Can be toggled by \\[time-stamp-toggle-active]. |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
101 See also the variable `time-stamp-warn-inactive'." |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
102 :type 'boolean |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
103 :group 'time-stamp) |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
104 |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
105 (defcustom time-stamp-warn-inactive t |
32454
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
106 "Have \\[time-stamp] warn if a buffer did not get time-stamped. |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
107 If non-nil, a warning is displayed if `time-stamp-active' has |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
108 deactivated time stamping and the buffer contains a template that |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
109 otherwise would have been updated." |
19504
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
110 :type 'boolean |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
111 :group 'time-stamp |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
112 :version "19.29") |
19504
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
113 |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
114 (defcustom time-stamp-old-format-warn 'ask |
32454
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
115 "Action if `time-stamp-format' is an old-style list. |
19504
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
116 If `error', the format is not used. If `ask', the user is queried about |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
117 using the time-stamp-format. If `warn', a warning is displayed. |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
118 If nil, no notification is given." |
34395
2f4a4d355834
(time-stamp-old-format-warn): reorder custom
Gerd Moellmann <gerd@gnu.org>
parents:
33033
diff
changeset
|
119 :type '(choice (const :tag "Don't use the format" error) |
2f4a4d355834
(time-stamp-old-format-warn): reorder custom
Gerd Moellmann <gerd@gnu.org>
parents:
33033
diff
changeset
|
120 (const ask) |
2f4a4d355834
(time-stamp-old-format-warn): reorder custom
Gerd Moellmann <gerd@gnu.org>
parents:
33033
diff
changeset
|
121 (const warn) |
2f4a4d355834
(time-stamp-old-format-warn): reorder custom
Gerd Moellmann <gerd@gnu.org>
parents:
33033
diff
changeset
|
122 (const :tag "No notification" nil)) |
19504
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
123 :group 'time-stamp) |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
124 |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
125 (defcustom time-stamp-time-zone nil |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
126 "If non-nil, a string naming the timezone to be used by \\[time-stamp]. |
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
127 Format is the same as that used by the environment variable TZ on your system." |
19791
1366d82c1d3f
(time-stamp-time-zone): Allow nil as alternative.
Richard M. Stallman <rms@gnu.org>
parents:
19504
diff
changeset
|
128 :type '(choice (const nil) string) |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
129 :group 'time-stamp |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
130 :version "20.1") |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
131 |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
132 |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
133 ;;; Do not change time-stamp-line-limit, time-stamp-start, |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
134 ;;; time-stamp-end, time-stamp-pattern, time-stamp-inserts-lines, |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
135 ;;; or time-stamp-count in your .emacs or you will be incompatible |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
136 ;;; with other people's files! If you must change them, do so only |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
137 ;;; in the local variables section of the file itself. |
3854 | 138 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
139 |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
140 (defvar time-stamp-line-limit 8 ;Do not change! |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
141 "Lines of a file searched; positive counts from start, negative from end. |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
142 The patterns `time-stamp-start' and `time-stamp-end' must be found in |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
143 the first (last) `time-stamp-line-limit' lines of the file for the |
24266
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
144 file to be time-stamped by \\[time-stamp]. A value of 0 searches the |
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
145 entire buffer (use with care). |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
146 |
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
147 This value can also be set with the variable `time-stamp-pattern'. |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
148 |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
149 Do not change `time-stamp-line-limit', `time-stamp-start', |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
150 `time-stamp-end', or `time-stamp-pattern' for yourself or you will be |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
151 incompatible with other people's files! If you must change them for some |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
152 application, do so in the local variables section of the time-stamped file |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
153 itself.") |
69980
f347a837af60
(time-stamp-format, time-stamp-line-limit)
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
154 ;;;###autoload(put 'time-stamp-line-limit 'safe-local-variable 'integerp) |
3854 | 155 |
5971
f97f4938fffa
(time-stamp-start): Allow more white space
Richard M. Stallman <rms@gnu.org>
parents:
5632
diff
changeset
|
156 (defvar time-stamp-start "Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change! |
3854 | 157 "Regexp after which the time stamp is written by \\[time-stamp]. |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
158 See also the variables `time-stamp-end' and `time-stamp-line-limit'. |
3854 | 159 |
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
160 This value can also be set with the variable `time-stamp-pattern'. |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
161 |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
162 Do not change `time-stamp-line-limit', `time-stamp-start', |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
163 `time-stamp-end', or `time-stamp-pattern' for yourself or you will be |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
164 incompatible with other people's files! If you must change them for some |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
165 application, do so in the local variables section of the time-stamped file |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
166 itself.") |
70218
d84cbfb84b06
(time-stamp-start, time-stamp-end, time-stamp-inserts-lines):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69980
diff
changeset
|
167 ;;;###autoload(put 'time-stamp-start 'safe-local-variable 'stringp) |
3854 | 168 |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
169 (defvar time-stamp-end "\\\\?[\">]" ;Do not change! |
3854 | 170 "Regexp marking the text after the time stamp. |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
171 \\[time-stamp] deletes the text between the first match of `time-stamp-start' |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
172 and the following match of `time-stamp-end', then writes the |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
173 time stamp specified by `time-stamp-format' between them. |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
174 |
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
175 This value can also be set with the variable `time-stamp-pattern'. |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
176 |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
177 The end text normally starts on the same line as the start text ends, |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
178 but if there are any newlines in `time-stamp-format', the same number |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
179 of newlines must separate the start and end. \\[time-stamp] tries |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
180 to not change the number of lines in the buffer. `time-stamp-inserts-lines' |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
181 controls this behavior. |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
182 |
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
183 Do not change `time-stamp-start', `time-stamp-end', `time-stamp-pattern', |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
184 or `time-stamp-inserts-lines' for yourself or you will be incompatible |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
185 with other people's files! If you must change them for some application, |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
186 do so in the local variables section of the time-stamped file itself.") |
70218
d84cbfb84b06
(time-stamp-start, time-stamp-end, time-stamp-inserts-lines):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69980
diff
changeset
|
187 ;;;###autoload(put 'time-stamp-end 'safe-local-variable 'stringp) |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
188 |
3854 | 189 |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
190 (defvar time-stamp-inserts-lines nil ;Do not change! |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
191 "Whether \\[time-stamp] can change the number of lines in a file. |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
192 If nil, \\[time-stamp] skips as many lines as there are newlines in |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
193 `time-stamp-format' before looking for the `time-stamp-end' pattern, |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
194 thus it tries not to change the number of lines in the buffer. |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
195 If non-nil, \\[time-stamp] starts looking for the end pattern |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
196 immediately after the start pattern. This behavior can cause |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
197 unexpected changes in the buffer if used carelessly, but it is useful |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
198 for generating repeated time stamps. |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
199 |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
200 Do not change `time-stamp-end' or `time-stamp-inserts-lines' for |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
201 yourself or you will be incompatible with other people's files! |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
202 If you must change them for some application, do so in the local |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
203 variables section of the time-stamped file itself.") |
70218
d84cbfb84b06
(time-stamp-start, time-stamp-end, time-stamp-inserts-lines):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69980
diff
changeset
|
204 ;;;###autoload(put 'time-stamp-inserts-lines 'safe-local-variable 'symbolp) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
205 |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
206 |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
207 (defvar time-stamp-count 1 ;Do not change! |
32454
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
208 "How many templates \\[time-stamp] will look for in a buffer. |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
209 The same time stamp will be written in each case. |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
210 |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
211 Do not change `time-stamp-count' for yourself or you will be |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
212 incompatible with other people's files! If you must change it for |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
213 some application, do so in the local variables section of the |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
214 time-stamped file itself.") |
69980
f347a837af60
(time-stamp-format, time-stamp-line-limit)
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
215 ;;;###autoload(put 'time-stamp-count 'safe-local-variable 'integerp) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
216 |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
217 |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
218 (defvar time-stamp-pattern nil ;Do not change! |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
219 "Convenience variable setting all `time-stamp' location and format values. |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
220 This string has four parts, each of which is optional. |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
221 These four parts set `time-stamp-line-limit', `time-stamp-start', |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
222 `time-stamp-format', and `time-stamp-end'. See the documentation |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
223 for each of these variables for details. |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
224 |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
225 The first part is a number followed by a slash; the number sets the number |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
226 of lines at the beginning (negative counts from end) of the file searched |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
227 for the time stamp. The number and the slash may be omitted to use the |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
228 normal value. |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
229 |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
230 The second part is a regexp identifying the pattern preceding the time stamp. |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
231 This part may be omitted to use the normal pattern. |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
232 |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
233 The third part specifies the format of the time stamp inserted. See |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
234 the documentation for `time-stamp-format' for details. Specify this |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
235 part as \"%%\" to use the normal format. |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
236 |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
237 The fourth part is a regexp identifying the pattern following the time stamp. |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
238 This part may be omitted to use the normal pattern. |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
239 |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
240 Examples: |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
241 \"-10/\" |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
242 \"-9/^Last modified: %%$\" |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
243 \"@set Time-stamp: %:b %:d, %:y$\" |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
244 \"newcommand{\\\\\\\\timestamp}{%%}\" |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
245 |
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
246 Do not change `time-stamp-pattern' `time-stamp-line-limit', |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
247 `time-stamp-start', or `time-stamp-end' for yourself or you will be |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
248 incompatible with other people's files! If you must change them for |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
249 some application, do so only in the local variables section of the |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
250 time-stamped file itself.") |
69980
f347a837af60
(time-stamp-format, time-stamp-line-limit)
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
251 ;;;###autoload(put 'time-stamp-pattern 'safe-local-variable 'stringp) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
252 |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
253 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
254 |
4327
771786f5d8c2
(time-stamp): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
4325
diff
changeset
|
255 ;;;###autoload |
3854 | 256 (defun time-stamp () |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
257 "Update the time stamp string(s) in the buffer. |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
258 A template in a file can be automatically updated with a new time stamp |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
259 every time you save the file. Add this line to your .emacs file: |
56074
7aab74a19427
(time-stamp): Recommend adding it to `before-save-hook', rather than
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
260 (add-hook 'before-save-hook 'time-stamp) |
56099
5c87de660fc1
(time-stamp): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
56074
diff
changeset
|
261 or customize `before-save-hook' through Custom. |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
262 Normally the template must appear in the first 8 lines of a file and |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
263 look like one of the following: |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
264 Time-stamp: <> |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
265 Time-stamp: \" \" |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
266 The time stamp is written between the brackets or quotes: |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
267 Time-stamp: <2001-02-18 10:20:51 gildea> |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
268 The time stamp is updated only if the variable `time-stamp-active' is non-nil. |
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
269 The format of the time stamp is set by the variable `time-stamp-pattern' or |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
270 `time-stamp-format'. The variables `time-stamp-pattern', |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
271 `time-stamp-line-limit', `time-stamp-start', `time-stamp-end', |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
272 `time-stamp-count', and `time-stamp-inserts-lines' control finding |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
273 the template." |
3854 | 274 (interactive) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
275 (let ((line-limit time-stamp-line-limit) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
276 (ts-start time-stamp-start) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
277 (ts-format time-stamp-format) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
278 (ts-end time-stamp-end) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
279 (ts-count time-stamp-count) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
280 (format-lines 0) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
281 (end-lines 1) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
282 (start nil) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
283 search-limit) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
284 (if (stringp time-stamp-pattern) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
285 (progn |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
286 (string-match "\\`\\(\\(-?[0-9]+\\)/\\)?\\([^%]+\\)?\\(\\(%[-.,:@+_ #^()0-9]*[A-Za-z%][^%]*\\)*%[-.,:@+_ #^()0-9]*[A-Za-z%]\\)?\\([^%]+\\)?\\'" time-stamp-pattern) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
287 (and (match-beginning 2) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
288 (setq line-limit |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
56099
diff
changeset
|
289 (string-to-number (match-string 2 time-stamp-pattern)))) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
290 (and (match-beginning 3) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
291 (setq ts-start (match-string 3 time-stamp-pattern))) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
292 (and (match-beginning 4) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
293 (not (string-equal (match-string 4 time-stamp-pattern) "%%")) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
294 (setq ts-format (match-string 4 time-stamp-pattern))) |
22508
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
295 (and (match-beginning 6) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
296 (setq ts-end (match-string 6 time-stamp-pattern))))) |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
297 (cond ((not (integerp line-limit)) |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
298 (setq line-limit 8) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
299 (message "time-stamp-line-limit is not an integer") |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
300 (sit-for 1))) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
301 (cond ((not (integerp ts-count)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
302 (setq ts-count 1) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
303 (message "time-stamp-count is not an integer") |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
304 (sit-for 1)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
305 ((< ts-count 1) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
306 ;; We need to call time-stamp-once at least once |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
307 ;; to output any warnings about time-stamp not being active. |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
308 (setq ts-count 1))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
309 ;; Figure out what lines the end should be on. |
32454
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
310 (if (stringp ts-format) |
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
311 (let ((nl-start 0)) |
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
312 (while (string-match "\n" ts-format nl-start) |
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
313 (setq format-lines (1+ format-lines) nl-start (match-end 0))))) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
314 (let ((nl-start 0)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
315 (while (string-match "\n" ts-end nl-start) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
316 (setq end-lines (1+ end-lines) nl-start (match-end 0)))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
317 ;; Find overall what lines to look at |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
318 (save-excursion |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
319 (save-restriction |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
320 (widen) |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
321 (cond ((> line-limit 0) |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
322 (goto-char (setq start (point-min))) |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
323 (forward-line line-limit) |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
324 (setq search-limit (point))) |
24266
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
325 ((< line-limit 0) |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
326 (goto-char (setq search-limit (point-max))) |
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
327 (forward-line line-limit) |
24266
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
328 (setq start (point))) |
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
329 (t ;0 => no limit (use with care!) |
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
330 (setq start (point-min)) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
331 (setq search-limit (point-max)))))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
332 (while (and start |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
333 (< start search-limit) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
334 (> ts-count 0)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
335 (setq start (time-stamp-once start search-limit ts-start ts-end |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
336 ts-format format-lines end-lines)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
337 (setq ts-count (1- ts-count)))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
338 nil) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
339 |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
340 (defun time-stamp-once (start search-limit ts-start ts-end |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
341 ts-format format-lines end-lines) |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
342 "Update one time stamp. Internal routine called by \\[time-stamp]. |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
343 Returns the end point, which is where `time-stamp' begins the next search." |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
344 (let ((case-fold-search nil) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
345 (end nil) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
346 end-search-start |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
347 (end-length nil)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
348 (save-excursion |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
349 (save-restriction |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
350 (widen) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
351 ;; Find the location of the time stamp. |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
352 (while (and (< (goto-char start) search-limit) |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
353 (not end) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
354 (re-search-forward ts-start search-limit 'move)) |
17600
0dc8180c2e7a
(time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents:
17438
diff
changeset
|
355 (setq start (point)) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
356 (if (not time-stamp-inserts-lines) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
357 (forward-line format-lines)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
358 (setq end-search-start (max start (point))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
359 (if (= (forward-line end-lines) 0) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
360 (progn |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
361 (and (bolp) (backward-char)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
362 (let ((line-end (min (point) search-limit))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
363 (if (>= line-end end-search-start) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
364 (progn |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
365 (goto-char end-search-start) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
366 (if (re-search-forward ts-end line-end t) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
367 (progn |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
368 (setq end (match-beginning 0)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
369 (setq end-length (- (match-end 0) end)))))))))))) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
370 (if end |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
371 (progn |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
372 ;; do all warnings outside save-excursion |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
373 (cond |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
374 ((not time-stamp-active) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
375 (if time-stamp-warn-inactive |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
376 ;; don't signal an error in a write-file-hook |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
377 (progn |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
378 (message "Warning: time-stamp-active is off; did not time-stamp buffer.") |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
379 (sit-for 1)))) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
380 ((not (and (stringp ts-start) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
381 (stringp ts-end))) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
382 (message "time-stamp-start or time-stamp-end is not a string") |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
383 (sit-for 1)) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
384 (t |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
385 (let ((new-time-stamp (time-stamp-string ts-format))) |
24266
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
386 (if (and (stringp new-time-stamp) |
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
387 (not (string-equal (buffer-substring start end) |
894911d2c01d
(time-stamp-format): Format doc tighter.
Richard M. Stallman <rms@gnu.org>
parents:
22993
diff
changeset
|
388 new-time-stamp))) |
21073
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
389 (save-excursion |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
390 (save-restriction |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
391 (widen) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
392 (delete-region start end) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
393 (goto-char start) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
394 (insert-and-inherit new-time-stamp) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
395 (setq end (point)) |
82e7d581bad1
(time-stamp-pattern): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19791
diff
changeset
|
396 ;; remove any tabs used to format time stamp |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
397 (if (search-backward "\t" start t) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
398 (progn |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
399 (untabify start end) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
400 (setq end (point)))))))))))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
401 ;; return the location after this time stamp, if there was one |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
402 (and end end-length |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
403 (+ end end-length)))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
404 |
3854 | 405 |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
406 ;;;###autoload |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
407 (defun time-stamp-toggle-active (&optional arg) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
408 "Toggle `time-stamp-active', setting whether \\[time-stamp] updates a buffer. |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
409 With ARG, turn time stamping on if and only if arg is positive." |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
410 (interactive "P") |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
411 (setq time-stamp-active |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
412 (if (null arg) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
413 (not time-stamp-active) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
414 (> (prefix-numeric-value arg) 0))) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
415 (message "time-stamp is now %s." (if time-stamp-active "active" "off"))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
416 |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
417 |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
418 (defun time-stamp-string (&optional ts-format) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
419 "Generate the new string to be inserted by \\[time-stamp]. |
35695
8bac5c752b89
(time-stamp-string): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
35627
diff
changeset
|
420 Optionally use format TS-FORMAT instead of `time-stamp-format' to |
8bac5c752b89
(time-stamp-string): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
35627
diff
changeset
|
421 format the string." |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
422 (or ts-format |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
423 (setq ts-format time-stamp-format)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
424 (if (stringp ts-format) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
425 (if (stringp time-stamp-time-zone) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
426 (let ((ts-real-time-zone (getenv "TZ"))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
427 (unwind-protect |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
428 (progn |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
429 (set-time-zone-rule time-stamp-time-zone) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
430 (format-time-string |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
431 (time-stamp-string-preprocess ts-format))) |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
432 (set-time-zone-rule ts-real-time-zone))) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
433 (format-time-string |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
434 (time-stamp-string-preprocess ts-format))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
435 ;; handle version 1 compatibility |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
436 (cond ((or (eq time-stamp-old-format-warn 'error) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
437 (and (eq time-stamp-old-format-warn 'ask) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
438 (not (y-or-n-p "Use non-string time-stamp-format? ")))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
439 (message "Warning: no time-stamp: time-stamp-format not a string") |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
440 (sit-for 1) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
441 nil) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
442 (t |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
443 (cond ((eq time-stamp-old-format-warn 'warn) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
444 (message "Obsolescent time-stamp-format type; should be string") |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
445 (sit-for 1))) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
446 (time-stamp-fconcat ts-format " "))))) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
447 |
16705
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
448 (defconst time-stamp-no-file "(no file)" |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
449 "String to use when the buffer is not associated with a file.") |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
450 |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
451 ;;; time-stamp is transitioning to using the new, expanded capabilities |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
452 ;;; of format-time-string. During the process, this function implements |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
453 ;;; intermediate, compatible formats and complains about old, soon to |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
454 ;;; be unsupported, formats. This function will get a lot (a LOT) shorter |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
455 ;;; when the transition is complete and we can just pass most things |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
456 ;;; straight through to format-time-string. |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
457 ;;; At all times, all the formats recommended in the doc string |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
458 ;;; of time-stamp-format will work not only in the current version of |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
459 ;;; Emacs, but in all versions that have been released within the past |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
460 ;;; two years. |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
461 ;;; The : modifier is a temporary conversion feature used to resolve |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
462 ;;; ambiguous formats--formats that are changing (over time) incompatibly. |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
463 (defun time-stamp-string-preprocess (format &optional time) |
35627 | 464 "Use a FORMAT to format date, time, file, and user information. |
465 Optional second argument TIME is only for testing. | |
466 Implements non-time extensions to `format-time-string' | |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
467 and all `time-stamp-format' compatibility." |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
468 (let ((fmt-len (length format)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
469 (ind 0) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
470 cur-char |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
471 (prev-char nil) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
472 (result "") |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
473 field-width |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
474 field-result |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
475 alt-form change-case require-padding |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
476 (paren-level 0)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
477 (while (< ind fmt-len) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
478 (setq cur-char (aref format ind)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
479 (setq |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
480 result |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
481 (concat result |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
482 (cond |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
483 ((eq cur-char ?%) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
484 ;; eat any additional args to allow for future expansion |
22508
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
485 (setq alt-form nil change-case nil require-padding nil field-width "") |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
486 (while (progn |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
487 (setq ind (1+ ind)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
488 (setq cur-char (if (< ind fmt-len) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
489 (aref format ind) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
490 ?\0)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
491 (or (eq ?. cur-char) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
492 (eq ?, cur-char) (eq ?: cur-char) (eq ?@ cur-char) |
35627 | 493 (eq ?- cur-char) (eq ?+ cur-char) (eq ?_ cur-char) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
494 (eq ?\ cur-char) (eq ?# cur-char) (eq ?^ cur-char) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
495 (and (eq ?\( cur-char) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
496 (not (eq prev-char ?\\)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
497 (setq paren-level (1+ paren-level))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
498 (if (and (eq ?\) cur-char) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
499 (not (eq prev-char ?\\)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
500 (> paren-level 0)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
501 (setq paren-level (1- paren-level)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
502 (and (> paren-level 0) |
22508
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
503 (< ind fmt-len))) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
504 (if (and (<= ?0 cur-char) (>= ?9 cur-char)) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
505 ;; get format width |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
506 (let ((field-index ind)) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
507 (while (progn |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
508 (setq ind (1+ ind)) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
509 (setq cur-char (if (< ind fmt-len) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
510 (aref format ind) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
511 ?\0)) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
512 (and (<= ?0 cur-char) (>= ?9 cur-char)))) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
513 (setq field-width (substring format field-index ind)) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
514 (setq ind (1- ind)) |
c9307c229265
(time-stamp): Handle newlines in time-stamp-pattern.
Karl Heuer <kwzh@gnu.org>
parents:
21073
diff
changeset
|
515 t)))) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
516 (setq prev-char cur-char) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
517 ;; some characters we actually use |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
518 (cond ((eq cur-char ?:) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
519 (setq alt-form t)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
520 ((eq cur-char ?#) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
521 (setq change-case t)))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
522 (setq field-result |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
523 (cond |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
524 ((eq cur-char ?%) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
525 "%%") |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
526 ((eq cur-char ?a) ;day of week |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
527 (if change-case |
39371
76ff4ba003e8
(time-stamp-string-preprocess): Fix bug that
Gerd Moellmann <gerd@gnu.org>
parents:
39229
diff
changeset
|
528 (format-time-string "%#a" time) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
529 (or alt-form (not (string-equal field-width "")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
530 (time-stamp-conv-warn "%a" "%:a")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
531 (if (and alt-form (not (string-equal field-width ""))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
532 "" ;discourage "%:3a" |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
533 (format-time-string "%A" time)))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
534 ((eq cur-char ?A) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
535 (if alt-form |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
536 (format-time-string "%A" time) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
537 (or change-case (not (string-equal field-width "")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
538 (time-stamp-conv-warn "%A" "%#A")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
539 (format-time-string "%#A" time))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
540 ((eq cur-char ?b) ;month name |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
541 (if change-case |
39371
76ff4ba003e8
(time-stamp-string-preprocess): Fix bug that
Gerd Moellmann <gerd@gnu.org>
parents:
39229
diff
changeset
|
542 (format-time-string "%#b" time) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
543 (or alt-form (not (string-equal field-width "")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
544 (time-stamp-conv-warn "%b" "%:b")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
545 (if (and alt-form (not (string-equal field-width ""))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
546 "" ;discourage "%:3b" |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
547 (format-time-string "%B" time)))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
548 ((eq cur-char ?B) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
549 (if alt-form |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
550 (format-time-string "%B" time) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
551 (or change-case (not (string-equal field-width "")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
552 (time-stamp-conv-warn "%B" "%#B")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
553 (format-time-string "%#B" time))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
554 ((eq cur-char ?d) ;day of month, 1-31 |
18171
566b6cf773ed
(time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents:
18170
diff
changeset
|
555 (time-stamp-do-number cur-char alt-form field-width time)) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
556 ((eq cur-char ?H) ;hour, 0-23 |
18171
566b6cf773ed
(time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents:
18170
diff
changeset
|
557 (time-stamp-do-number cur-char alt-form field-width time)) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
558 ((eq cur-char ?I) ;hour, 1-12 |
18171
566b6cf773ed
(time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents:
18170
diff
changeset
|
559 (time-stamp-do-number cur-char alt-form field-width time)) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
560 ((eq cur-char ?m) ;month number, 1-12 |
18171
566b6cf773ed
(time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents:
18170
diff
changeset
|
561 (time-stamp-do-number cur-char alt-form field-width time)) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
562 ((eq cur-char ?M) ;minute, 0-59 |
18171
566b6cf773ed
(time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents:
18170
diff
changeset
|
563 (time-stamp-do-number cur-char alt-form field-width time)) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
564 ((eq cur-char ?p) ;am or pm |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
565 (or change-case |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
566 (time-stamp-conv-warn "%p" "%#p")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
567 (format-time-string "%#p" time)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
568 ((eq cur-char ?P) ;AM or PM |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
569 (format-time-string "%p" time)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
570 ((eq cur-char ?S) ;seconds, 00-60 |
18171
566b6cf773ed
(time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents:
18170
diff
changeset
|
571 (time-stamp-do-number cur-char alt-form field-width time)) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
572 ((eq cur-char ?w) ;weekday number, Sunday is 0 |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
573 (format-time-string "%w" time)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
574 ((eq cur-char ?y) ;year |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
575 (or alt-form (not (string-equal field-width "")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
576 (time-stamp-conv-warn "%y" "%:y")) |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
56099
diff
changeset
|
577 (string-to-number (format-time-string "%Y" time))) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
578 ((eq cur-char ?Y) ;4-digit year, new style |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
56099
diff
changeset
|
579 (string-to-number (format-time-string "%Y" time))) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
580 ((eq cur-char ?z) ;time zone lower case |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
581 (if change-case |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
582 "" ;discourage %z variations |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
583 (format-time-string "%#Z" time))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
584 ((eq cur-char ?Z) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
585 (if change-case |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
586 (format-time-string "%#Z" time) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
587 (format-time-string "%Z" time))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
588 ((eq cur-char ?f) ;buffer-file-name, base name only |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
589 (if buffer-file-name |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
590 (file-name-nondirectory buffer-file-name) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
591 time-stamp-no-file)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
592 ((eq cur-char ?F) ;buffer-file-name, full path |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
593 (or buffer-file-name |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
594 time-stamp-no-file)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
595 ((eq cur-char ?s) ;system name |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
596 (system-name)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
597 ((eq cur-char ?u) ;user name |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
598 (user-login-name)) |
22993
f580b9694876
(time-stamp-string-preprocess): Add %U code.
Richard M. Stallman <rms@gnu.org>
parents:
22508
diff
changeset
|
599 ((eq cur-char ?U) ;user full name |
f580b9694876
(time-stamp-string-preprocess): Add %U code.
Richard M. Stallman <rms@gnu.org>
parents:
22508
diff
changeset
|
600 (user-full-name)) |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
601 ((eq cur-char ?l) ;logname (undocumented user name alt) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
602 (user-login-name)) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
603 ((eq cur-char ?L) ;(undocumented alt user full name) |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
604 (user-full-name)) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
605 ((eq cur-char ?h) ;mail host name |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
606 (time-stamp-mail-host-name)) |
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
607 ((eq cur-char ?q) ;(undocumented unqual hostname) |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
608 (let ((qualname (system-name))) |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
609 (if (string-match "\\." qualname) |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
610 (substring qualname 0 (match-beginning 0)) |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
611 qualname))) |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
612 ((eq cur-char ?Q) ;(undocumented fully-qualified host) |
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
64762
diff
changeset
|
613 (system-name)) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
614 )) |
32874
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
615 (let ((padded-result |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
616 (format (format "%%%s%c" |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
617 field-width |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
618 (if (numberp field-result) ?d ?s)) |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
619 (or field-result "")))) |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
620 (let* ((initial-length (length padded-result)) |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
621 (desired-length (if (string-equal field-width "") |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
622 initial-length |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
56099
diff
changeset
|
623 (string-to-number field-width)))) |
32874
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
624 (if (> initial-length desired-length) |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
625 ;; truncate strings on right, years on left |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
626 (if (stringp field-result) |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
627 (substring padded-result 0 desired-length) |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
628 (if (eq cur-char ?y) |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
629 (substring padded-result (- desired-length)) |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
630 padded-result)) ;non-year numbers don't truncate |
12f068b4d5ac
(time-stamp-string-preprocess): Fix a wrong
Gerd Moellmann <gerd@gnu.org>
parents:
32454
diff
changeset
|
631 padded-result)))) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
632 (t |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
633 (char-to-string cur-char))))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
634 (setq ind (1+ ind))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
635 result)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
636 |
18171
566b6cf773ed
(time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents:
18170
diff
changeset
|
637 (defun time-stamp-do-number (format-char alt-form field-width time) |
35627 | 638 "Handle compatible FORMAT-CHAR where only default width/padding will change. |
639 ALT-FORM is whether `#' specified. FIELD-WIDTH is the string | |
640 width specification or \"\". TIME is the time to convert." | |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
641 (let ((format-string (concat "%" (char-to-string format-char)))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
642 (and (not alt-form) (string-equal field-width "") |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
643 (time-stamp-conv-warn format-string |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
644 (format "%%:%c" format-char))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
645 (if (and alt-form (not (string-equal field-width ""))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
646 "" ;discourage "%:2d" and the like |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
56099
diff
changeset
|
647 (string-to-number (format-time-string format-string time))))) |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
648 |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
649 (defvar time-stamp-conversion-warn t |
32454
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
650 "Warn about soon-to-be-unsupported forms in `time-stamp-format'. |
08bfb5555d7b
(time-stamp): Fixed bug in new multi-line code
Gerd Moellmann <gerd@gnu.org>
parents:
28696
diff
changeset
|
651 If nil, these warnings are disabled, which would be a bad idea! |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
652 You really need to update your files instead. |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
653 |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
654 The new formats will work with old versions of Emacs. |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
655 New formats are being recommended now to allow `time-stamp-format' |
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
656 to change in the future to be compatible with `format-time-string'. |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
657 The new forms being recommended now will continue to work then.") |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
658 |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
659 |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
660 (defun time-stamp-conv-warn (old-form new-form) |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
661 "Display a warning about a soon-to-be-obsolete format. |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
662 Suggests replacing OLD-FORM with NEW-FORM." |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
663 (cond |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
664 (time-stamp-conversion-warn |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
665 (save-excursion |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
666 (set-buffer (get-buffer-create "*Time-stamp-compatibility*")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
667 (goto-char (point-max)) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
668 (if (bobp) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
669 (progn |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
670 (insert |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
671 "The formats recognized in time-stamp-format will change in a future release\n" |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
672 "to be compatible with the new, expanded format-time-string function.\n\n" |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
673 "The following obsolescent time-stamp-format construct(s) were found:\n\n"))) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
674 (insert "\"" old-form "\" -- use " new-form "\n")) |
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
675 (display-buffer "*Time-stamp-compatibility*")))) |
19504
fd1ee3c25839
(time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19154
diff
changeset
|
676 |
18170
7776ee6215de
(time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents:
17600
diff
changeset
|
677 |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
678 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
679 (defun time-stamp-mail-host-name () |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
680 "Return the name of the host where the user receives mail. |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
681 This is the value of `mail-host-address' if bound and a string, |
25405
456e2e2bc4d3
Put quote-backquote around all symbol names
Karl Heuer <kwzh@gnu.org>
parents:
24266
diff
changeset
|
682 otherwise the value of the function `system-name'." |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
683 (or (and (boundp 'mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
684 (stringp mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
685 mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
686 (system-name))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
687 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
688 ;;; the rest of this file is for version 1 compatibility |
3854 | 689 |
690 (defun time-stamp-fconcat (list sep) | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
691 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals. |
3854 | 692 If an element of LIST is a symbol, it is funcalled to get the string to use; |
693 the separator SEP is used between two strings obtained by funcalling a | |
694 symbol. Otherwise the element itself is inserted; no separator is used | |
695 around literals." | |
696 (let ((return-string "") | |
697 (insert-sep-p nil)) | |
698 (while list | |
699 (cond ((symbolp (car list)) | |
700 (if insert-sep-p | |
701 (setq return-string (concat return-string sep))) | |
702 (setq return-string (concat return-string (funcall (car list)))) | |
703 (setq insert-sep-p t)) | |
704 (t | |
705 (setq return-string (concat return-string (car list))) | |
706 (setq insert-sep-p nil))) | |
707 (setq list (cdr list))) | |
708 return-string)) | |
709 | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
710 ;;; Some functions used in time-stamp-format |
3854 | 711 |
49559
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
712 ;;; These functions have been obsolete since 1995 |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
713 ;;; and will be removed in Emacs 22. |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
714 ;;; Meanwhile, discourage other packages from using them. |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
715 (let ((obsolete-functions '(time-stamp-month-dd-yyyy |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
716 time-stamp-dd/mm/yyyy |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
717 time-stamp-mon-dd-yyyy |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
718 time-stamp-dd-mon-yy |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
719 time-stamp-yy/mm/dd |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
720 time-stamp-yyyy/mm/dd |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
721 time-stamp-yyyy-mm-dd |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
722 time-stamp-yymmdd |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
723 time-stamp-hh:mm:ss |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
724 time-stamp-hhmm))) |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
725 (while obsolete-functions |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
726 (make-obsolete (car obsolete-functions) |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
727 "use time-stamp-string or format-time-string instead." |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
728 "20.1") |
fcde0602da01
Update example date in preamble commentary.
Stephen Gildea <gildea@stop.mail-abuse.org>
parents:
47437
diff
changeset
|
729 (setq obsolete-functions (cdr obsolete-functions)))) |
3854 | 730 |
731 ;;; pretty form, suitable for a title page | |
732 | |
733 (defun time-stamp-month-dd-yyyy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
734 "Return the current date as a string in \"Month DD, YYYY\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
735 (format-time-string "%B %e, %Y")) |
3854 | 736 |
16517
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
737 (defun time-stamp-dd/mm/yyyy () |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
738 "Return the current date as a string in \"DD/MM/YYYY\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
739 (format-time-string "%d/%m/%Y")) |
16517
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
740 |
3854 | 741 ;;; same as __DATE__ in ANSI C |
742 | |
743 (defun time-stamp-mon-dd-yyyy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
744 "Return the current date as a string in \"Mon DD YYYY\" form. |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
745 The first character of DD is space if the value is less than 10." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
746 (format-time-string "%b %d %Y")) |
3854 | 747 |
748 ;;; RFC 822 date | |
749 | |
750 (defun time-stamp-dd-mon-yy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
751 "Return the current date as a string in \"DD Mon YY\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
752 (format-time-string "%d %b %y")) |
3854 | 753 |
754 ;;; RCS 3 date | |
755 | |
756 (defun time-stamp-yy/mm/dd () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
757 "Return the current date as a string in \"YY/MM/DD\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
758 (format-time-string "%y/%m/%d")) |
3854 | 759 |
760 ;;; RCS 5 date | |
761 | |
762 (defun time-stamp-yyyy/mm/dd () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
763 "Return the current date as a string in \"YYYY/MM/DD\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
764 (format-time-string "%Y/%m/%d")) |
3854 | 765 |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
766 ;;; ISO 8601 date |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
767 |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
768 (defun time-stamp-yyyy-mm-dd () |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
769 "Return the current date as a string in \"YYYY-MM-DD\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
770 (format-time-string "%Y-%m-%d")) |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
771 |
3854 | 772 (defun time-stamp-yymmdd () |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
773 "Return the current date as a string in \"YYMMDD\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
774 (format-time-string "%y%m%d")) |
3854 | 775 |
776 (defun time-stamp-hh:mm:ss () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
777 "Return the current time as a string in \"HH:MM:SS\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
778 (format-time-string "%T")) |
3854 | 779 |
780 (defun time-stamp-hhmm () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
781 "Return the current time as a string in \"HHMM\" form." |
16706
450cb7cbf895
(time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents:
16705
diff
changeset
|
782 (format-time-string "%H%M")) |
3854 | 783 |
784 (provide 'time-stamp) | |
785 | |
52401 | 786 ;;; arch-tag: 8a12c5c3-25d6-4a71-adc5-24b0e025a1e7 |
3854 | 787 ;;; time-stamp.el ends here |