3854
|
1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
|
|
2
|
64762
|
3 ;; Copyright (C) 1989, 1993, 1994, 1995, 1997, 2000, 2001, 2002, 2003,
|
79721
|
4 ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
14169
|
5
|
38436
|
6 ;; This file is part of GNU Emacs.
|
|
7
|
69980
|
8 ;; Maintainer's Time-stamp: <2006-04-12 20:30:56 rms>
|
39229
|
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
|
78236
|
14 ;; the Free Software Foundation; either version 3, or (at your option)
|
3854
|
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
|
29 ;; A template in a file can be updated with a new time stamp when
|
|
30 ;; you save the file. For example:
|
49559
|
31 ;; static char *ts = "sdmain.c Time-stamp: <2001-08-13 10:20:51 gildea>";
|
16287
|
32 ;; See the top of `time-stamp.el' for another example.
|
3854
|
33
|
16287
|
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>
diff
changeset
|
35 ;; (add-hook 'before-save-hook 'time-stamp)
|
16287
|
36 ;; Now any time-stamp templates in your files will be updated automatically.
|
3854
|
37
|
16287
|
38 ;; See the documentation for the functions `time-stamp'
|
|
39 ;; and `time-stamp-toggle-active' for details.
|
11404
|
40
|
3854
|
41 ;;; Code:
|
|
42
|
17438
|
43 (defgroup time-stamp nil
|
|
44 "Maintain last change time stamps in files edited by Emacs."
|
|
45 :group 'data
|
|
46 :group 'extensions)
|
|
47
|
18170
|
48 (defcustom time-stamp-format "%:y-%02m-%02d %02H:%02M:%02S %u"
|
16287
|
49 "*Format of the string inserted by \\[time-stamp].
|
16674
|
50 The value may be a string or a list. Lists are supported only for
|
|
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>
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>
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>
diff
changeset
|
57 \(`C') locale.
|
16705
|
58
|
18170
|
59 %:a weekday name: `Monday'. %#A gives uppercase: `MONDAY'
|
|
60 %3a abbreviated weekday: `Mon'. %3A gives uppercase: `MON'
|
|
61 %:b month name: `January'. %#B gives uppercase: `JANUARY'
|
|
62 %3b abbreviated month: `Jan'. %3B gives uppercase: `JAN'
|
|
63 %02d day of month
|
|
64 %02H 24-hour clock hour
|
|
65 %02I 12-hour clock hour
|
|
66 %02m month number
|
|
67 %02M minute
|
|
68 %#p `am' or `pm'. %P gives uppercase: `AM' or `PM'
|
|
69 %02S seconds
|
|
70 %w day number of week, Sunday is 0
|
49559
|
71 %02y 2-digit year: `03' %:y 4-digit year: `2003'
|
18170
|
72 %z time zone name: `est'. %Z gives uppercase: `EST'
|
|
73
|
|
74 Non-date items:
|
|
75 %% a literal percent character: `%'
|
|
76 %f file name without directory %F gives absolute pathname
|
|
77 %s system name
|
24266
|
78 %u user's login name %U user's full name
|
18170
|
79 %h mail host name
|
|
80
|
|
81 Decimal digits between the % and the type character specify the
|
|
82 field width. Strings are truncated on the right; years on the left.
|
25405
|
83 A leading zero in the field width zero-fills a number.
|
17600
|
84
|
|
85 For example, to get the format used by the `date' command,
|
18170
|
86 use \"%3a %3b %2d %02H:%02M:%02S %Z %:y\".
|
|
87
|
25405
|
88 In the future these formats will be aligned more with `format-time-string'.
|
18170
|
89 Because of this transition, the default padding for numeric formats will
|
|
90 change in a future version. Therefore either a padding width should be
|
|
91 specified, or the : modifier should be used to explicitly request the
|
|
92 historical default."
|
17438
|
93 :type 'string
|
49559
|
94 :group 'time-stamp
|
|
95 :version "20.1")
|
69980
|
96 ;;;###autoload(put 'time-stamp-format 'safe-local-variable 'stringp)
|
16287
|
97
|
19504
|
98 (defcustom time-stamp-active t
|
|
99 "*Non-nil to enable time-stamping of buffers by \\[time-stamp].
|
|
100 Can be toggled by \\[time-stamp-toggle-active].
|
|
101 See also the variable `time-stamp-warn-inactive'."
|
|
102 :type 'boolean
|
|
103 :group 'time-stamp)
|
|
104
|
|
105 (defcustom time-stamp-warn-inactive t
|
32454
|
106 "Have \\[time-stamp] warn if a buffer did not get time-stamped.
|
49559
|
107 If non-nil, a warning is displayed if `time-stamp-active' has
|
|
108 deactivated time stamping and the buffer contains a template that
|
|
109 otherwise would have been updated."
|
19504
|
110 :type 'boolean
|
49559
|
111 :group 'time-stamp
|
|
112 :version "19.29")
|
19504
|
113
|
|
114 (defcustom time-stamp-old-format-warn 'ask
|
32454
|
115 "Action if `time-stamp-format' is an old-style list.
|
19504
|
116 If `error', the format is not used. If `ask', the user is queried about
|
|
117 using the time-stamp-format. If `warn', a warning is displayed.
|
|
118 If nil, no notification is given."
|
34395
|
119 :type '(choice (const :tag "Don't use the format" error)
|
|
120 (const ask)
|
|
121 (const warn)
|
|
122 (const :tag "No notification" nil))
|
19504
|
123 :group 'time-stamp)
|
|
124
|
|
125 (defcustom time-stamp-time-zone nil
|
|
126 "If non-nil, a string naming the timezone to be used by \\[time-stamp].
|
|
127 Format is the same as that used by the environment variable TZ on your system."
|
19791
|
128 :type '(choice (const nil) string)
|
49559
|
129 :group 'time-stamp
|
|
130 :version "20.1")
|
79664
f1154b4e2454
* time-stamp.el (time-stamp-time-zone): Add safe-local-variable property.
Dan Nicolaescu <dann@ics.uci.edu>
diff
changeset
|
131 ;;;###autoload(put 'time-stamp-time-zone 'safe-local-variable 'string-or-null-p)
|
17600
|
132
|
21073
|
133 ;;; Do not change time-stamp-line-limit, time-stamp-start,
|
25405
|
134 ;;; time-stamp-end, time-stamp-pattern, time-stamp-inserts-lines,
|
|
135 ;;; or time-stamp-count in your .emacs or you will be incompatible
|
|
136 ;;; with other people's files! If you must change them, do so only
|
|
137 ;;; in the local variables section of the file itself.
|
3854
|
138
|
16287
|
139
|
5632
|
140 (defvar time-stamp-line-limit 8 ;Do not change!
|
14042
|
141 "Lines of a file searched; positive counts from start, negative from end.
|
25405
|
142 The patterns `time-stamp-start' and `time-stamp-end' must be found in
|
|
143 the first (last) `time-stamp-line-limit' lines of the file for the
|
24266
|
144 file to be time-stamped by \\[time-stamp]. A value of 0 searches the
|
|
145 entire buffer (use with care).
|
5632
|
146
|
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
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>
diff
changeset
|
148
|
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
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>
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>
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>
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>
diff
changeset
|
153 itself.")
|
69980
|
154 ;;;###autoload(put 'time-stamp-line-limit 'safe-local-variable 'integerp)
|
3854
|
155
|
5971
|
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
|
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>
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>
diff
changeset
|
161
|
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
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>
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>
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>
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>
diff
changeset
|
166 itself.")
|
70218
d84cbfb84b06
(time-stamp-start, time-stamp-end, time-stamp-inserts-lines):
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
167 ;;;###autoload(put 'time-stamp-start 'safe-local-variable 'stringp)
|
3854
|
168
|
5632
|
169 (defvar time-stamp-end "\\\\?[\">]" ;Do not change!
|
3854
|
170 "Regexp marking the text after the time stamp.
|
5632
|
171 \\[time-stamp] deletes the text between the first match of `time-stamp-start'
|
25405
|
172 and the following match of `time-stamp-end', then writes the
|
|
173 time stamp specified by `time-stamp-format' between them.
|
5632
|
174
|
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
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>
diff
changeset
|
176
|
25405
|
177 The end text normally starts on the same line as the start text ends,
|
|
178 but if there are any newlines in `time-stamp-format', the same number
|
|
179 of newlines must separate the start and end. \\[time-stamp] tries
|
|
180 to not change the number of lines in the buffer. `time-stamp-inserts-lines'
|
|
181 controls this behavior.
|
|
182
|
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
diff
changeset
|
183 Do not change `time-stamp-start', `time-stamp-end', `time-stamp-pattern',
|
25405
|
184 or `time-stamp-inserts-lines' for yourself or you will be incompatible
|
5632
|
185 with other people's files! If you must change them for some application,
|
|
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>
diff
changeset
|
187 ;;;###autoload(put 'time-stamp-end 'safe-local-variable 'stringp)
|
5632
|
188
|
3854
|
189
|
25405
|
190 (defvar time-stamp-inserts-lines nil ;Do not change!
|
49559
|
191 "Whether \\[time-stamp] can change the number of lines in a file.
|
25405
|
192 If nil, \\[time-stamp] skips as many lines as there are newlines in
|
|
193 `time-stamp-format' before looking for the `time-stamp-end' pattern,
|
|
194 thus it tries not to change the number of lines in the buffer.
|
|
195 If non-nil, \\[time-stamp] starts looking for the end pattern
|
|
196 immediately after the start pattern. This behavior can cause
|
|
197 unexpected changes in the buffer if used carelessly, but it is useful
|
|
198 for generating repeated time stamps.
|
|
199
|
|
200 Do not change `time-stamp-end' or `time-stamp-inserts-lines' for
|
|
201 yourself or you will be incompatible with other people's files!
|
|
202 If you must change them for some application, do so in the local
|
|
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>
diff
changeset
|
204 ;;;###autoload(put 'time-stamp-inserts-lines 'safe-local-variable 'symbolp)
|
25405
|
205
|
|
206
|
|
207 (defvar time-stamp-count 1 ;Do not change!
|
32454
|
208 "How many templates \\[time-stamp] will look for in a buffer.
|
49559
|
209 The same time stamp will be written in each case.
|
25405
|
210
|
|
211 Do not change `time-stamp-count' for yourself or you will be
|
|
212 incompatible with other people's files! If you must change it for
|
|
213 some application, do so in the local variables section of the
|
|
214 time-stamped file itself.")
|
69980
|
215 ;;;###autoload(put 'time-stamp-count 'safe-local-variable 'integerp)
|
25405
|
216
|
|
217
|
49559
|
218 (defvar time-stamp-pattern nil ;Do not change!
|
25405
|
219 "Convenience variable setting all `time-stamp' location and format values.
|
21073
|
220 This string has four parts, each of which is optional.
|
25405
|
221 These four parts set `time-stamp-line-limit', `time-stamp-start',
|
|
222 `time-stamp-format', and `time-stamp-end'. See the documentation
|
21073
|
223 for each of these variables for details.
|
|
224
|
|
225 The first part is a number followed by a slash; the number sets the number
|
|
226 of lines at the beginning (negative counts from end) of the file searched
|
49559
|
227 for the time stamp. The number and the slash may be omitted to use the
|
21073
|
228 normal value.
|
|
229
|
|
230 The second part is a regexp identifying the pattern preceding the time stamp.
|
|
231 This part may be omitted to use the normal pattern.
|
|
232
|
49559
|
233 The third part specifies the format of the time stamp inserted. See
|
25405
|
234 the documentation for `time-stamp-format' for details. Specify this
|
21073
|
235 part as \"%%\" to use the normal format.
|
|
236
|
|
237 The fourth part is a regexp identifying the pattern following the time stamp.
|
|
238 This part may be omitted to use the normal pattern.
|
|
239
|
49559
|
240 Examples:
|
|
241 \"-10/\"
|
|
242 \"-9/^Last modified: %%$\"
|
|
243 \"@set Time-stamp: %:b %:d, %:y$\"
|
|
244 \"newcommand{\\\\\\\\timestamp}{%%}\"
|
21073
|
245
|
65449
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
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>
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>
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>
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>
diff
changeset
|
250 time-stamped file itself.")
|
69980
|
251 ;;;###autoload(put 'time-stamp-pattern 'safe-local-variable 'stringp)
|
21073
|
252
|
|
253
|
16287
|
254
|
4327
|
255 ;;;###autoload
|
3854
|
256 (defun time-stamp ()
|
25405
|
257 "Update the time stamp string(s) in the buffer.
|
16287
|
258 A template in a file can be automatically updated with a new time stamp
|
|
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>
diff
changeset
|
260 (add-hook 'before-save-hook 'time-stamp)
|
56099
|
261 or customize `before-save-hook' through Custom.
|
16287
|
262 Normally the template must appear in the first 8 lines of a file and
|
|
263 look like one of the following:
|
|
264 Time-stamp: <>
|
|
265 Time-stamp: \" \"
|
|
266 The time stamp is written between the brackets or quotes:
|
49559
|
267 Time-stamp: <2001-02-18 10:20:51 gildea>
|
17600
|
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>
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>
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>
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>
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>
diff
changeset
|
273 the template."
|
3854
|
274 (interactive)
|
25405
|
275 (let ((line-limit time-stamp-line-limit)
|
21073
|
276 (ts-start time-stamp-start)
|
|
277 (ts-format time-stamp-format)
|
25405
|
278 (ts-end time-stamp-end)
|
|
279 (ts-count time-stamp-count)
|
|
280 (format-lines 0)
|
|
281 (end-lines 1)
|
|
282 (start nil)
|
|
283 search-limit)
|
21073
|
284 (if (stringp time-stamp-pattern)
|
|
285 (progn
|
49559
|
286 (string-match "\\`\\(\\(-?[0-9]+\\)/\\)?\\([^%]+\\)?\\(\\(%[-.,:@+_ #^()0-9]*[A-Za-z%][^%]*\\)*%[-.,:@+_ #^()0-9]*[A-Za-z%]\\)?\\([^%]+\\)?\\'" time-stamp-pattern)
|
21073
|
287 (and (match-beginning 2)
|
|
288 (setq line-limit
|
62402
|
289 (string-to-number (match-string 2 time-stamp-pattern))))
|
21073
|
290 (and (match-beginning 3)
|
|
291 (setq ts-start (match-string 3 time-stamp-pattern)))
|
|
292 (and (match-beginning 4)
|
|
293 (not (string-equal (match-string 4 time-stamp-pattern) "%%"))
|
|
294 (setq ts-format (match-string 4 time-stamp-pattern)))
|
22508
|
295 (and (match-beginning 6)
|
|
296 (setq ts-end (match-string 6 time-stamp-pattern)))))
|
17600
|
297 (cond ((not (integerp line-limit))
|
|
298 (setq line-limit 8)
|
21073
|
299 (message "time-stamp-line-limit is not an integer")
|
17600
|
300 (sit-for 1)))
|
25405
|
301 (cond ((not (integerp ts-count))
|
|
302 (setq ts-count 1)
|
|
303 (message "time-stamp-count is not an integer")
|
|
304 (sit-for 1))
|
|
305 ((< ts-count 1)
|
|
306 ;; We need to call time-stamp-once at least once
|
|
307 ;; to output any warnings about time-stamp not being active.
|
|
308 (setq ts-count 1)))
|
|
309 ;; Figure out what lines the end should be on.
|
32454
|
310 (if (stringp ts-format)
|
|
311 (let ((nl-start 0))
|
|
312 (while (string-match "\n" ts-format nl-start)
|
|
313 (setq format-lines (1+ format-lines) nl-start (match-end 0)))))
|
25405
|
314 (let ((nl-start 0))
|
|
315 (while (string-match "\n" ts-end nl-start)
|
|
316 (setq end-lines (1+ end-lines) nl-start (match-end 0))))
|
|
317 ;; Find overall what lines to look at
|
17600
|
318 (save-excursion
|
|
319 (save-restriction
|
|
320 (widen)
|
|
321 (cond ((> line-limit 0)
|
|
322 (goto-char (setq start (point-min)))
|
|
323 (forward-line line-limit)
|
|
324 (setq search-limit (point)))
|
24266
|
325 ((< line-limit 0)
|
17600
|
326 (goto-char (setq search-limit (point-max)))
|
|
327 (forward-line line-limit)
|
24266
|
328 (setq start (point)))
|
|
329 (t ;0 => no limit (use with care!)
|
|
330 (setq start (point-min))
|
25405
|
331 (setq search-limit (point-max))))))
|
|
332 (while (and start
|
|
333 (< start search-limit)
|
|
334 (> ts-count 0))
|
|
335 (setq start (time-stamp-once start search-limit ts-start ts-end
|
|
336 ts-format format-lines end-lines))
|
|
337 (setq ts-count (1- ts-count))))
|
|
338 nil)
|
|
339
|
|
340 (defun time-stamp-once (start search-limit ts-start ts-end
|
|
341 ts-format format-lines end-lines)
|
49559
|
342 "Update one time stamp. Internal routine called by \\[time-stamp].
|
25405
|
343 Returns the end point, which is where `time-stamp' begins the next search."
|
|
344 (let ((case-fold-search nil)
|
|
345 (end nil)
|
|
346 end-search-start
|
|
347 (end-length nil))
|
|
348 (save-excursion
|
|
349 (save-restriction
|
|
350 (widen)
|
|
351 ;; Find the location of the time stamp.
|
|
352 (while (and (< (goto-char start) search-limit)
|
17600
|
353 (not end)
|
21073
|
354 (re-search-forward ts-start search-limit 'move))
|
17600
|
355 (setq start (point))
|
25405
|
356 (if (not time-stamp-inserts-lines)
|
|
357 (forward-line format-lines))
|
|
358 (setq end-search-start (max start (point)))
|
|
359 (if (= (forward-line end-lines) 0)
|
|
360 (progn
|
|
361 (and (bolp) (backward-char))
|
|
362 (let ((line-end (min (point) search-limit)))
|
|
363 (if (>= line-end end-search-start)
|
|
364 (progn
|
|
365 (goto-char end-search-start)
|
|
366 (if (re-search-forward ts-end line-end t)
|
|
367 (progn
|
|
368 (setq end (match-beginning 0))
|
|
369 (setq end-length (- (match-end 0) end))))))))))))
|
21073
|
370 (if end
|
|
371 (progn
|
|
372 ;; do all warnings outside save-excursion
|
|
373 (cond
|
|
374 ((not time-stamp-active)
|
|
375 (if time-stamp-warn-inactive
|
|
376 ;; don't signal an error in a write-file-hook
|
|
377 (progn
|
|
378 (message "Warning: time-stamp-active is off; did not time-stamp buffer.")
|
|
379 (sit-for 1))))
|
|
380 ((not (and (stringp ts-start)
|
|
381 (stringp ts-end)))
|
|
382 (message "time-stamp-start or time-stamp-end is not a string")
|
|
383 (sit-for 1))
|
|
384 (t
|
|
385 (let ((new-time-stamp (time-stamp-string ts-format)))
|
24266
|
386 (if (and (stringp new-time-stamp)
|
|
387 (not (string-equal (buffer-substring start end)
|
|
388 new-time-stamp)))
|
21073
|
389 (save-excursion
|
|
390 (save-restriction
|
|
391 (widen)
|
|
392 (delete-region start end)
|
|
393 (goto-char start)
|
|
394 (insert-and-inherit new-time-stamp)
|
|
395 (setq end (point))
|
|
396 ;; remove any tabs used to format time stamp
|
25405
|
397 (if (search-backward "\t" start t)
|
|
398 (progn
|
|
399 (untabify start end)
|
|
400 (setq end (point))))))))))))
|
|
401 ;; return the location after this time stamp, if there was one
|
|
402 (and end end-length
|
|
403 (+ end end-length))))
|
|
404
|
3854
|
405
|
11404
|
406 ;;;###autoload
|
|
407 (defun time-stamp-toggle-active (&optional arg)
|
16287
|
408 "Toggle `time-stamp-active', setting whether \\[time-stamp] updates a buffer.
|
49559
|
409 With ARG, turn time stamping on if and only if arg is positive."
|
11404
|
410 (interactive "P")
|
|
411 (setq time-stamp-active
|
|
412 (if (null arg)
|
|
413 (not time-stamp-active)
|
|
414 (> (prefix-numeric-value arg) 0)))
|
25405
|
415 (message "time-stamp is now %s." (if time-stamp-active "active" "off")))
|
|
416
|
|
417
|
|
418 (defun time-stamp-string (&optional ts-format)
|
|
419 "Generate the new string to be inserted by \\[time-stamp].
|
35695
|
420 Optionally use format TS-FORMAT instead of `time-stamp-format' to
|
|
421 format the string."
|
25405
|
422 (or ts-format
|
|
423 (setq ts-format time-stamp-format))
|
|
424 (if (stringp ts-format)
|
|
425 (if (stringp time-stamp-time-zone)
|
|
426 (let ((ts-real-time-zone (getenv "TZ")))
|
|
427 (unwind-protect
|
|
428 (progn
|
49559
|
429 (set-time-zone-rule time-stamp-time-zone)
|
25405
|
430 (format-time-string
|
|
431 (time-stamp-string-preprocess ts-format)))
|
49559
|
432 (set-time-zone-rule ts-real-time-zone)))
|
25405
|
433 (format-time-string
|
|
434 (time-stamp-string-preprocess ts-format)))
|
|
435 ;; handle version 1 compatibility
|
|
436 (cond ((or (eq time-stamp-old-format-warn 'error)
|
|
437 (and (eq time-stamp-old-format-warn 'ask)
|
|
438 (not (y-or-n-p "Use non-string time-stamp-format? "))))
|
|
439 (message "Warning: no time-stamp: time-stamp-format not a string")
|
|
440 (sit-for 1)
|
|
441 nil)
|
|
442 (t
|
|
443 (cond ((eq time-stamp-old-format-warn 'warn)
|
|
444 (message "Obsolescent time-stamp-format type; should be string")
|
|
445 (sit-for 1)))
|
|
446 (time-stamp-fconcat ts-format " ")))))
|
16287
|
447
|
16705
|
448 (defconst time-stamp-no-file "(no file)"
|
|
449 "String to use when the buffer is not associated with a file.")
|
|
450
|
18170
|
451 ;;; time-stamp is transitioning to using the new, expanded capabilities
|
|
452 ;;; of format-time-string. During the process, this function implements
|
|
453 ;;; intermediate, compatible formats and complains about old, soon to
|
|
454 ;;; be unsupported, formats. This function will get a lot (a LOT) shorter
|
|
455 ;;; when the transition is complete and we can just pass most things
|
|
456 ;;; straight through to format-time-string.
|
|
457 ;;; At all times, all the formats recommended in the doc string
|
|
458 ;;; of time-stamp-format will work not only in the current version of
|
|
459 ;;; Emacs, but in all versions that have been released within the past
|
|
460 ;;; two years.
|
|
461 ;;; The : modifier is a temporary conversion feature used to resolve
|
|
462 ;;; ambiguous formats--formats that are changing (over time) incompatibly.
|
|
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
|
467 and all `time-stamp-format' compatibility."
|
18170
|
468 (let ((fmt-len (length format))
|
|
469 (ind 0)
|
|
470 cur-char
|
|
471 (prev-char nil)
|
|
472 (result "")
|
|
473 field-width
|
|
474 field-result
|
|
475 alt-form change-case require-padding
|
|
476 (paren-level 0))
|
|
477 (while (< ind fmt-len)
|
|
478 (setq cur-char (aref format ind))
|
|
479 (setq
|
|
480 result
|
|
481 (concat result
|
|
482 (cond
|
|
483 ((eq cur-char ?%)
|
|
484 ;; eat any additional args to allow for future expansion
|
22508
|
485 (setq alt-form nil change-case nil require-padding nil field-width "")
|
18170
|
486 (while (progn
|
|
487 (setq ind (1+ ind))
|
|
488 (setq cur-char (if (< ind fmt-len)
|
|
489 (aref format ind)
|
|
490 ?\0))
|
|
491 (or (eq ?. cur-char)
|
|
492 (eq ?, cur-char) (eq ?: cur-char) (eq ?@ cur-char)
|
35627
|
493 (eq ?- cur-char) (eq ?+ cur-char) (eq ?_ cur-char)
|
74245
|
494 (eq ?\s cur-char) (eq ?# cur-char) (eq ?^ cur-char)
|
18170
|
495 (and (eq ?\( cur-char)
|
|
496 (not (eq prev-char ?\\))
|
|
497 (setq paren-level (1+ paren-level)))
|
|
498 (if (and (eq ?\) cur-char)
|
|
499 (not (eq prev-char ?\\))
|
|
500 (> paren-level 0))
|
|
501 (setq paren-level (1- paren-level))
|
|
502 (and (> paren-level 0)
|
22508
|
503 (< ind fmt-len)))
|
|
504 (if (and (<= ?0 cur-char) (>= ?9 cur-char))
|
|
505 ;; get format width
|
|
506 (let ((field-index ind))
|
|
507 (while (progn
|
|
508 (setq ind (1+ ind))
|
|
509 (setq cur-char (if (< ind fmt-len)
|
|
510 (aref format ind)
|
|
511 ?\0))
|
|
512 (and (<= ?0 cur-char) (>= ?9 cur-char))))
|
|
513 (setq field-width (substring format field-index ind))
|
|
514 (setq ind (1- ind))
|
|
515 t))))
|
18170
|
516 (setq prev-char cur-char)
|
|
517 ;; some characters we actually use
|
|
518 (cond ((eq cur-char ?:)
|
|
519 (setq alt-form t))
|
|
520 ((eq cur-char ?#)
|
|
521 (setq change-case t))))
|
|
522 (setq field-result
|
|
523 (cond
|
|
524 ((eq cur-char ?%)
|
25405
|
525 "%%")
|
18170
|
526 ((eq cur-char ?a) ;day of week
|
|
527 (if change-case
|
39371
|
528 (format-time-string "%#a" time)
|
18170
|
529 (or alt-form (not (string-equal field-width ""))
|
|
530 (time-stamp-conv-warn "%a" "%:a"))
|
|
531 (if (and alt-form (not (string-equal field-width "")))
|
|
532 "" ;discourage "%:3a"
|
|
533 (format-time-string "%A" time))))
|
|
534 ((eq cur-char ?A)
|
|
535 (if alt-form
|
|
536 (format-time-string "%A" time)
|
|
537 (or change-case (not (string-equal field-width ""))
|
|
538 (time-stamp-conv-warn "%A" "%#A"))
|
|
539 (format-time-string "%#A" time)))
|
|
540 ((eq cur-char ?b) ;month name
|
|
541 (if change-case
|
39371
|
542 (format-time-string "%#b" time)
|
18170
|
543 (or alt-form (not (string-equal field-width ""))
|
|
544 (time-stamp-conv-warn "%b" "%:b"))
|
|
545 (if (and alt-form (not (string-equal field-width "")))
|
|
546 "" ;discourage "%:3b"
|
|
547 (format-time-string "%B" time))))
|
|
548 ((eq cur-char ?B)
|
|
549 (if alt-form
|
|
550 (format-time-string "%B" time)
|
|
551 (or change-case (not (string-equal field-width ""))
|
|
552 (time-stamp-conv-warn "%B" "%#B"))
|
|
553 (format-time-string "%#B" time)))
|
|
554 ((eq cur-char ?d) ;day of month, 1-31
|
18171
|
555 (time-stamp-do-number cur-char alt-form field-width time))
|
18170
|
556 ((eq cur-char ?H) ;hour, 0-23
|
18171
|
557 (time-stamp-do-number cur-char alt-form field-width time))
|
18170
|
558 ((eq cur-char ?I) ;hour, 1-12
|
18171
|
559 (time-stamp-do-number cur-char alt-form field-width time))
|
18170
|
560 ((eq cur-char ?m) ;month number, 1-12
|
18171
|
561 (time-stamp-do-number cur-char alt-form field-width time))
|
18170
|
562 ((eq cur-char ?M) ;minute, 0-59
|
18171
|
563 (time-stamp-do-number cur-char alt-form field-width time))
|
18170
|
564 ((eq cur-char ?p) ;am or pm
|
|
565 (or change-case
|
|
566 (time-stamp-conv-warn "%p" "%#p"))
|
|
567 (format-time-string "%#p" time))
|
|
568 ((eq cur-char ?P) ;AM or PM
|
|
569 (format-time-string "%p" time))
|
|
570 ((eq cur-char ?S) ;seconds, 00-60
|
18171
|
571 (time-stamp-do-number cur-char alt-form field-width time))
|
18170
|
572 ((eq cur-char ?w) ;weekday number, Sunday is 0
|
|
573 (format-time-string "%w" time))
|
|
574 ((eq cur-char ?y) ;year
|
|
575 (or alt-form (not (string-equal field-width ""))
|
|
576 (time-stamp-conv-warn "%y" "%:y"))
|
62402
|
577 (string-to-number (format-time-string "%Y" time)))
|
18170
|
578 ((eq cur-char ?Y) ;4-digit year, new style
|
62402
|
579 (string-to-number (format-time-string "%Y" time)))
|
18170
|
580 ((eq cur-char ?z) ;time zone lower case
|
|
581 (if change-case
|
|
582 "" ;discourage %z variations
|
|
583 (format-time-string "%#Z" time)))
|
|
584 ((eq cur-char ?Z)
|
|
585 (if change-case
|
|
586 (format-time-string "%#Z" time)
|
|
587 (format-time-string "%Z" time)))
|
|
588 ((eq cur-char ?f) ;buffer-file-name, base name only
|
|
589 (if buffer-file-name
|
|
590 (file-name-nondirectory buffer-file-name)
|
|
591 time-stamp-no-file))
|
|
592 ((eq cur-char ?F) ;buffer-file-name, full path
|
|
593 (or buffer-file-name
|
|
594 time-stamp-no-file))
|
|
595 ((eq cur-char ?s) ;system name
|
|
596 (system-name))
|
|
597 ((eq cur-char ?u) ;user name
|
|
598 (user-login-name))
|
22993
|
599 ((eq cur-char ?U) ;user full name
|
|
600 (user-full-name))
|
25405
|
601 ((eq cur-char ?l) ;logname (undocumented user name alt)
|
|
602 (user-login-name))
|
|
603 ((eq cur-char ?L) ;(undocumented alt user full name)
|
|
604 (user-full-name))
|
18170
|
605 ((eq cur-char ?h) ;mail host name
|
|
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>
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>
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>
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>
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>
diff
changeset
|
611 qualname)))
|
d3d35c792c79
(time-stamp, time-stamp-line-limit, time-stamp-start, time-stamp-end):
Stephen Gildea <gildea@stop.mail-abuse.org>
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>
diff
changeset
|
613 (system-name))
|
18170
|
614 ))
|
32874
|
615 (let ((padded-result
|
|
616 (format (format "%%%s%c"
|
|
617 field-width
|
|
618 (if (numberp field-result) ?d ?s))
|
|
619 (or field-result ""))))
|
|
620 (let* ((initial-length (length padded-result))
|
|
621 (desired-length (if (string-equal field-width "")
|
|
622 initial-length
|
62402
|
623 (string-to-number field-width))))
|
32874
|
624 (if (> initial-length desired-length)
|
|
625 ;; truncate strings on right, years on left
|
|
626 (if (stringp field-result)
|
|
627 (substring padded-result 0 desired-length)
|
|
628 (if (eq cur-char ?y)
|
|
629 (substring padded-result (- desired-length))
|
|
630 padded-result)) ;non-year numbers don't truncate
|
|
631 padded-result))))
|
18170
|
632 (t
|
|
633 (char-to-string cur-char)))))
|
|
634 (setq ind (1+ ind)))
|
|
635 result))
|
|
636
|
18171
|
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
|
641 (let ((format-string (concat "%" (char-to-string format-char))))
|
|
642 (and (not alt-form) (string-equal field-width "")
|
|
643 (time-stamp-conv-warn format-string
|
|
644 (format "%%:%c" format-char)))
|
|
645 (if (and alt-form (not (string-equal field-width "")))
|
|
646 "" ;discourage "%:2d" and the like
|
62402
|
647 (string-to-number (format-time-string format-string time)))))
|
18170
|
648
|
|
649 (defvar time-stamp-conversion-warn t
|
32454
|
650 "Warn about soon-to-be-unsupported forms in `time-stamp-format'.
|
|
651 If nil, these warnings are disabled, which would be a bad idea!
|
18170
|
652 You really need to update your files instead.
|
|
653
|
|
654 The new formats will work with old versions of Emacs.
|
25405
|
655 New formats are being recommended now to allow `time-stamp-format'
|
|
656 to change in the future to be compatible with `format-time-string'.
|
18170
|
657 The new forms being recommended now will continue to work then.")
|
|
658
|
|
659
|
|
660 (defun time-stamp-conv-warn (old-form new-form)
|
49559
|
661 "Display a warning about a soon-to-be-obsolete format.
|
|
662 Suggests replacing OLD-FORM with NEW-FORM."
|
18170
|
663 (cond
|
|
664 (time-stamp-conversion-warn
|
|
665 (save-excursion
|
|
666 (set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
|
|
667 (goto-char (point-max))
|
|
668 (if (bobp)
|
|
669 (progn
|
|
670 (insert
|
|
671 "The formats recognized in time-stamp-format will change in a future release\n"
|
|
672 "to be compatible with the new, expanded format-time-string function.\n\n"
|
|
673 "The following obsolescent time-stamp-format construct(s) were found:\n\n")))
|
|
674 (insert "\"" old-form "\" -- use " new-form "\n"))
|
|
675 (display-buffer "*Time-stamp-compatibility*"))))
|
19504
|
676
|
18170
|
677
|
11404
|
678
|
|
679 (defun time-stamp-mail-host-name ()
|
|
680 "Return the name of the host where the user receives mail.
|
|
681 This is the value of `mail-host-address' if bound and a string,
|
25405
|
682 otherwise the value of the function `system-name'."
|
11404
|
683 (or (and (boundp 'mail-host-address)
|
|
684 (stringp mail-host-address)
|
|
685 mail-host-address)
|
|
686 (system-name)))
|
|
687
|
|
688 ;;; the rest of this file is for version 1 compatibility
|
3854
|
689
|
|
690 (defun time-stamp-fconcat (list sep)
|
5632
|
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
|
710 ;;; Some functions used in time-stamp-format
|
3854
|
711
|
49559
|
712 ;;; These functions have been obsolete since 1995
|
90104
|
713 ;;; and will be removed in Emacs 23.
|
49559
|
714 ;;; Meanwhile, discourage other packages from using them.
|
74247
|
715 (dolist (function '(time-stamp-month-dd-yyyy time-stamp-dd/mm/yyyy
|
|
716 time-stamp-mon-dd-yyyy time-stamp-dd-mon-yy
|
|
717 time-stamp-yy/mm/dd time-stamp-yyyy/mm/dd
|
|
718 time-stamp-yyyy-mm-dd time-stamp-yymmdd
|
|
719 time-stamp-hh:mm:ss time-stamp-hhmm))
|
|
720 (make-obsolete function
|
|
721 "use `time-stamp-string' or `format-time-string' instead."
|
|
722 "20.1"))
|
3854
|
723
|
|
724 ;;; pretty form, suitable for a title page
|
|
725
|
|
726 (defun time-stamp-month-dd-yyyy ()
|
5632
|
727 "Return the current date as a string in \"Month DD, YYYY\" form."
|
16706
|
728 (format-time-string "%B %e, %Y"))
|
3854
|
729
|
16517
|
730 (defun time-stamp-dd/mm/yyyy ()
|
|
731 "Return the current date as a string in \"DD/MM/YYYY\" form."
|
16706
|
732 (format-time-string "%d/%m/%Y"))
|
16517
|
733
|
3854
|
734 ;;; same as __DATE__ in ANSI C
|
|
735
|
|
736 (defun time-stamp-mon-dd-yyyy ()
|
5632
|
737 "Return the current date as a string in \"Mon DD YYYY\" form.
|
|
738 The first character of DD is space if the value is less than 10."
|
16706
|
739 (format-time-string "%b %d %Y"))
|
3854
|
740
|
|
741 ;;; RFC 822 date
|
|
742
|
|
743 (defun time-stamp-dd-mon-yy ()
|
5632
|
744 "Return the current date as a string in \"DD Mon YY\" form."
|
16706
|
745 (format-time-string "%d %b %y"))
|
3854
|
746
|
|
747 ;;; RCS 3 date
|
|
748
|
|
749 (defun time-stamp-yy/mm/dd ()
|
5632
|
750 "Return the current date as a string in \"YY/MM/DD\" form."
|
16706
|
751 (format-time-string "%y/%m/%d"))
|
3854
|
752
|
|
753 ;;; RCS 5 date
|
|
754
|
|
755 (defun time-stamp-yyyy/mm/dd ()
|
5632
|
756 "Return the current date as a string in \"YYYY/MM/DD\" form."
|
16706
|
757 (format-time-string "%Y/%m/%d"))
|
3854
|
758
|
5632
|
759 ;;; ISO 8601 date
|
|
760
|
|
761 (defun time-stamp-yyyy-mm-dd ()
|
|
762 "Return the current date as a string in \"YYYY-MM-DD\" form."
|
16706
|
763 (format-time-string "%Y-%m-%d"))
|
5632
|
764
|
3854
|
765 (defun time-stamp-yymmdd ()
|
5632
|
766 "Return the current date as a string in \"YYMMDD\" form."
|
16706
|
767 (format-time-string "%y%m%d"))
|
3854
|
768
|
|
769 (defun time-stamp-hh:mm:ss ()
|
5632
|
770 "Return the current time as a string in \"HH:MM:SS\" form."
|
16706
|
771 (format-time-string "%T"))
|
3854
|
772
|
|
773 (defun time-stamp-hhmm ()
|
5632
|
774 "Return the current time as a string in \"HHMM\" form."
|
16706
|
775 (format-time-string "%H%M"))
|
3854
|
776
|
|
777 (provide 'time-stamp)
|
|
778
|
52401
|
779 ;;; arch-tag: 8a12c5c3-25d6-4a71-adc5-24b0e025a1e7
|
3854
|
780 ;;; time-stamp.el ends here
|