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