Mercurial > emacs
annotate lisp/time-stamp.el @ 16663:773436c9b680 libc-961211 libc-961212 libc-961213 libc-961214 libc-961215 libc-961216 libc-961217 libc-961218 libc-961219 libc-961220 libc-961221 libc-961222 libc-961223 libc-961224 libc-961225 libc-961226 libc-961227 libc-961228 libc-961229 libc-961230 libc-961231
* config.guess: Recognize machten.
From Eric W. Bates <ericx@vineyard.net>.
author | David J. MacKenzie <djm@gnu.org> |
---|---|
date | Wed, 11 Dec 1996 00:37:52 +0000 |
parents | 1fa5a347e70f |
children | 91590d8f74c3 |
rev | line source |
---|---|
3854 | 1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs |
2 | |
14169 | 3 ;; Copyright 1989, 1993, 1994, 1995 Free Software Foundation, Inc. |
4 | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
5 ;; Maintainer's Time-stamp: <1996-08-13 14:03:17 gildea> |
3854 | 6 ;; Maintainer: Stephen Gildea <gildea@lcs.mit.edu> |
7 ;; Keywords: tools | |
8 | |
9 ;; This file is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; This file is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
3854 | 23 |
24 ;;; Commentary: | |
25 | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
26 ;; 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
|
27 ;; you save the file. For example: |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
28 ;; static char *ts = "sdmain.c Time-stamp: <1996-08-13 10:20:51 gildea>"; |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
29 ;; See the top of `time-stamp.el' for another example. |
3854 | 30 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
31 ;; To use time-stamping, add this line to your .emacs file: |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
32 ;; (add-hook 'write-file-hooks 'time-stamp) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
33 ;; Now any time-stamp templates in your files will be updated automatically. |
3854 | 34 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
35 ;; 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
|
36 ;; 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
|
37 |
14231
069791dced1e
Fix Change Log comment line.
Erik Naggum <erik@naggum.no>
parents:
14169
diff
changeset
|
38 ;;; Change Log: |
3854 | 39 |
14169 | 40 ;; Originally based on the 19 Dec 88 version of |
41 ;; date.el by John Sturdy <mcvax!harlqn.co.uk!jcgs@uunet.uu.net> | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
42 ;; Version 2, January 1995: replaced functions with %-escapes |
16517
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
43 ;; $Id: time-stamp.el,v 1.19 1996/09/22 22:20:58 kwzh Exp rms $ |
3854 | 44 |
45 ;;; Code: | |
46 | |
47 (defvar time-stamp-active t | |
13356 | 48 "*Non-nil to enable time-stamping of buffers by \\[time-stamp]. |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
49 Can be toggled by \\[time-stamp-toggle-active]. |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
50 See also the variable `time-stamp-warn-inactive'.") |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
51 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
52 (defvar time-stamp-warn-inactive t |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
53 "Non-nil to have \\[time-stamp] warn if a buffer did not get time-stamped. |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
54 A warning is printed if `time-stamp-active' is nil and the buffer contains |
13356 | 55 a time stamp template that would otherwise have been updated.") |
3854 | 56 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
57 (defvar time-stamp-old-format-warn 'ask |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
58 "Action to take if `time-stamp-format' is an old-style list. |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
59 If 'error, the format is not used. If 'ask, the user is queried about |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
60 using the time-stamp-format. If 'warn, a warning is displayed. |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
61 If nil, no notification is given.") |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
62 |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
63 (defvar time-stamp-format "%y-%02m-%02d %02H:%02M:%02S %u" |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
64 "*Format of the string inserted by \\[time-stamp]. |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
65 Value may be a string or a list. (Lists are supported only for |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
66 backward compatibility; see variable `time-stamp-old-format-warn'.) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
67 A string is used verbatim except for character sequences beginning with %: |
13356 | 68 |
69 %a weekday name: `Monday'. %A gives uppercase: `MONDAY' | |
70 %b month name: `January'. %B gives uppercase: `JANUARY' | |
71 %d day of month | |
72 %H 24-hour clock hour | |
73 %I 12-hour clock hour | |
74 %m month number | |
75 %M minute | |
76 %p `am' or `pm'. %P gives uppercase: `AM' or `PM' | |
77 %S seconds | |
78 %w day number of week, Sunday is 0 | |
79 %y year: `1995' | |
80 %z time zone name: `est'. %Z gives uppercase: `EST' | |
81 | |
82 Non-date items: | |
83 %% a literal percent character: `%' | |
84 %f file name without directory %F gives absolute pathname | |
85 %s system name | |
86 %u user's login name | |
87 %h mail host name | |
88 | |
89 Decimal digits between the % and the type character specify the | |
90 field width. Strings are truncated on the right; numbers on the left. | |
91 A leading zero causes numbers to be zero-filled. | |
92 | |
93 For example, to get the format used by the `date' command, | |
94 use \"%3a %3b %2d %02H:%02M:%02S %Z %y\"") | |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
95 |
3854 | 96 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
97 |
3854 | 98 ;;; Do not change time-stamp-line-limit, time-stamp-start, or |
99 ;;; time-stamp-end in your .emacs or you will be incompatible | |
100 ;;; with other people's files! If you must change them, | |
101 ;;; do so only in the local variables section of the file itself. | |
102 | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
103 |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
104 (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
|
105 "Lines of a file searched; positive counts from start, negative from end. |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
106 The patterns `time-stamp-start' and `time-stamp-end' must be found on one |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
107 of the first (last) `time-stamp-line-limit' lines of the file for the |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
108 file to be time-stamped by \\[time-stamp]. |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
109 |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
110 Do not change `time-stamp-line-limit', `time-stamp-start', or |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
111 `time-stamp-end' for yourself or you will be incompatible |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
112 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
|
113 do so in the local variables section of the time-stamped file itself.") |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
114 |
3854 | 115 |
5971
f97f4938fffa
(time-stamp-start): Allow more white space
Richard M. Stallman <rms@gnu.org>
parents:
5632
diff
changeset
|
116 (defvar time-stamp-start "Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change! |
3854 | 117 "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
|
118 See also the variables `time-stamp-end' and `time-stamp-line-limit'. |
3854 | 119 |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
120 Do not change `time-stamp-line-limit', `time-stamp-start', or |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
121 `time-stamp-end' for yourself or you will be incompatible |
3854 | 122 with other people's files! If you must change them for some application, |
123 do so in the local variables section of the time-stamped file itself.") | |
124 | |
125 | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
126 (defvar time-stamp-end "\\\\?[\">]" ;Do not change! |
3854 | 127 "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
|
128 \\[time-stamp] deletes the text between the first match of `time-stamp-start' |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
129 and the following match of `time-stamp-end' on the same line, |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
130 then writes the time stamp specified by `time-stamp-format' between them. |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
131 |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
132 Do not change `time-stamp-line-limit', `time-stamp-start', or |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
133 `time-stamp-end' for yourself or you will be incompatible |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
134 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
|
135 do so in the local variables section of the time-stamped file itself.") |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
136 |
3854 | 137 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
138 |
4327
771786f5d8c2
(time-stamp): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
4325
diff
changeset
|
139 ;;;###autoload |
3854 | 140 (defun time-stamp () |
141 "Update the time stamp string in the buffer. | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
142 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
|
143 every time you save the file. Add this line to your .emacs file: |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
144 (add-hook 'write-file-hooks 'time-stamp) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
145 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
|
146 look like one of the following: |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
147 Time-stamp: <> |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
148 Time-stamp: \" \" |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
149 The time stamp is written between the brackets or quotes: |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
150 Time-stamp: <1996-07-18 10:20:51 gildea> |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
151 Only updates the time stamp if the variable `time-stamp-active' is non-nil. |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
152 The format of the time stamp is set by the variable `time-stamp-format'. |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
153 The variables `time-stamp-line-limit', `time-stamp-start', |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
154 and `time-stamp-end' control finding the template." |
3854 | 155 (interactive) |
12023
1a3e7aef5f8a
(time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents:
11429
diff
changeset
|
156 (let ((case-fold-search nil) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
157 (start nil) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
158 (end nil) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
159 search-limit) |
12023
1a3e7aef5f8a
(time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents:
11429
diff
changeset
|
160 (save-excursion |
1a3e7aef5f8a
(time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents:
11429
diff
changeset
|
161 (save-restriction |
1a3e7aef5f8a
(time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents:
11429
diff
changeset
|
162 (widen) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
163 (cond ((> time-stamp-line-limit 0) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
164 (goto-char (setq start (point-min))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
165 (forward-line time-stamp-line-limit) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
166 (setq search-limit (point))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
167 (t |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
168 (goto-char (setq search-limit (point-max))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
169 (forward-line time-stamp-line-limit) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
170 (setq start (point)))) |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
171 (goto-char start) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
172 (while (and (< (point) search-limit) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
173 (not end) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
174 (re-search-forward time-stamp-start search-limit 'move)) |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
175 (setq start (point)) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
176 (end-of-line) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
177 (let ((line-end (point))) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
178 (goto-char start) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
179 (if (re-search-forward time-stamp-end line-end 'move) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
180 (setq end (match-beginning 0))))))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
181 (if end |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
182 (progn |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
183 ;; do all warnings outside save-excursion |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
184 (cond |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
185 ((not time-stamp-active) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
186 (if time-stamp-warn-inactive |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
187 ;; don't signal an error in a write-file-hook |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
188 (progn |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
189 (message "Warning: time-stamp-active is off; did not time-stamp buffer.") |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
190 (sit-for 1)))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
191 ((not (and (stringp time-stamp-start) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
192 (stringp time-stamp-end))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
193 (message "time-stamp-start or time-stamp-end is not a string") |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
194 (sit-for 1)) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
195 (t |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
196 (let ((new-time-stamp (time-stamp-string))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
197 (if (stringp new-time-stamp) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
198 (save-excursion |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
199 (save-restriction |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
200 (widen) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
201 (delete-region start end) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
202 (goto-char start) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
203 (insert new-time-stamp) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
204 (setq end (point)) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
205 ;; remove any tabs used to format time stamp |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
206 (goto-char start) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
207 (if (search-forward "\t" end t) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
208 (untabify start end))))))))))) |
3854 | 209 ;; be sure to return nil so can be used on write-file-hooks |
210 nil) | |
211 | |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
212 ;;;###autoload |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
213 (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
|
214 "Toggle `time-stamp-active', setting whether \\[time-stamp] updates a buffer. |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
215 With arg, turn time stamping on if and only if arg is positive." |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
216 (interactive "P") |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
217 (setq time-stamp-active |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
218 (if (null arg) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
219 (not time-stamp-active) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
220 (> (prefix-numeric-value arg) 0))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
221 (message "time-stamp is now %s." (if time-stamp-active "active" "off"))) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
222 |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
223 |
3854 | 224 (defun time-stamp-string () |
225 "Generate the new string to be inserted by \\[time-stamp]." | |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
226 (if (stringp time-stamp-format) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
227 (time-stamp-strftime time-stamp-format) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
228 ;; handle version 1 compatibility |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
229 (cond ((or (eq time-stamp-old-format-warn 'error) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
230 (and (eq time-stamp-old-format-warn 'ask) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
231 (not (y-or-n-p "Use non-string time-stamp-format? ")))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
232 (message "Warning: no time-stamp: time-stamp-format not a string") |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
233 (sit-for 1) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
234 nil) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
235 (t |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
236 (cond ((eq time-stamp-old-format-warn 'warn) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
237 (message "Obsolescent time-stamp-format type; should be string") |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
238 (sit-for 1))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
239 (time-stamp-fconcat time-stamp-format " "))))) |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
240 |
12044
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
241 (defconst time-stamp-month-numbers |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
242 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6) |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
243 ("Jul" . 7) ("Aug" . 8) ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12)) |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
244 "Alist of months and their number.") |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
245 |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
246 (defconst time-stamp-month-full-names |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
247 ["(zero)" "January" "February" "March" "April" "May" "June" |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
248 "July" "August" "September" "October" "November" "December"]) |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
249 |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
250 (defconst time-stamp-weekday-numbers |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
251 '(("Sun" . 0) ("Mon" . 1) ("Tue" . 2) ("Wed" . 3) |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
252 ("Thu" . 4) ("Fri" . 5) ("Sat" . 6)) |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
253 "Alist of weekdays and their number.") |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
254 |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
255 (defconst time-stamp-weekday-full-names |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
256 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"]) |
091ae363ac1c
Move defconsts to avoid byte-compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents:
12023
diff
changeset
|
257 |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
258 (defconst time-stamp-am-pm '("am" "pm") |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
259 "List of strings used to denote morning and afternoon.") |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
260 |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
261 (defconst time-stamp-no-file "(no file)" |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
262 "String to use when the buffer is not associated with a file.") |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
263 |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
264 (defun time-stamp-strftime (format &optional time) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
265 "Uses a FORMAT to format date, time, file, and user information. |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
266 Optional second argument TIME will be used instead of the current time. |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
267 See the documentation of the variable `time-stamp-format' for a description |
13356 | 268 of the format string." |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
269 (let ((time-string (cond ((stringp time) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
270 time) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
271 (time |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
272 (current-time-string time)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
273 (t |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
274 (current-time-string)))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
275 (fmt-len (length format)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
276 (ind 0) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
277 cur-char |
13356 | 278 (prev-char nil) |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
279 (result "") |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
280 field-index |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
281 field-width |
13356 | 282 field-result |
283 (paren-level 0)) | |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
284 (while (< ind fmt-len) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
285 (setq cur-char (aref format ind)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
286 (setq |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
287 result |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
288 (concat result |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
289 (cond |
13356 | 290 ((eq cur-char ?%) |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
291 (setq field-index (1+ ind)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
292 (while (progn |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
293 (setq ind (1+ ind)) |
13356 | 294 (setq cur-char (if (< ind fmt-len) |
295 (aref format ind) | |
296 ?\0)) | |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
297 (and (<= ?0 cur-char) (>= ?9 cur-char)))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
298 (setq field-width (substring format field-index ind)) |
13356 | 299 ;; eat any additional args to allow for future expansion |
300 (while (or (and (<= ?0 cur-char) (>= ?9 cur-char)) (eq ?. cur-char) | |
301 (eq ?, cur-char) (eq ?: cur-char) (eq ?@ cur-char) | |
302 (eq ?- cur-char) (eq ?+ cur-char) | |
303 (eq ?\ cur-char) (eq ?# cur-char) | |
304 (and (eq ?\( cur-char) | |
305 (not (eq prev-char ?\\)) | |
306 (setq paren-level (1+ paren-level))) | |
307 (if (and (eq ?\) cur-char) | |
308 (not (eq prev-char ?\\)) | |
309 (> paren-level 0)) | |
310 (setq paren-level (1- paren-level)) | |
311 (and (> paren-level 0) | |
312 (< ind fmt-len)))) | |
313 (setq ind (1+ ind)) | |
314 (setq prev-char cur-char) | |
315 (setq cur-char (if (< ind fmt-len) | |
316 (aref format ind) | |
317 ?\0))) | |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
318 (setq field-result |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
319 (cond |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
320 ((eq cur-char ?%) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
321 "%") |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
322 ((or (eq cur-char ?a) ;weekday name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
323 (eq cur-char ?A)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
324 (let ((name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
325 (aref time-stamp-weekday-full-names |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
326 (cdr (assoc (substring time-string 0 3) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
327 time-stamp-weekday-numbers))))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
328 (if (eq cur-char ?a) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
329 name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
330 (upcase name)))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
331 ((or (eq cur-char ?b) ;month name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
332 (eq cur-char ?B)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
333 (let ((name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
334 (aref time-stamp-month-full-names |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
335 (cdr (assoc (substring time-string 4 7) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
336 time-stamp-month-numbers))))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
337 (if (eq cur-char ?b) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
338 name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
339 (upcase name)))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
340 ((eq cur-char ?d) ;day of month, 1-31 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
341 (string-to-int (substring time-string 8 10))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
342 ((eq cur-char ?H) ;hour, 0-23 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
343 (string-to-int (substring time-string 11 13))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
344 ((eq cur-char ?I) ;hour, 1-12 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
345 (let ((hour (string-to-int (substring time-string 11 13)))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
346 (cond ((< hour 1) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
347 (+ hour 12)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
348 ((> hour 12) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
349 (- hour 12)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
350 (t |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
351 hour)))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
352 ((eq cur-char ?m) ;month number, 1-12 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
353 (cdr (assoc (substring time-string 4 7) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
354 time-stamp-month-numbers))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
355 ((eq cur-char ?M) ;minute, 0-59 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
356 (string-to-int (substring time-string 14 16))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
357 ((or (eq cur-char ?p) ;am or pm |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
358 (eq cur-char ?P)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
359 (let ((name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
360 (if (> 12 (string-to-int (substring time-string 11 13))) |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
361 (car time-stamp-am-pm) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
362 (car (cdr time-stamp-am-pm))))) |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
363 (if (eq cur-char ?p) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
364 name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
365 (upcase name)))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
366 ((eq cur-char ?S) ;seconds, 00-60 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
367 (string-to-int (substring time-string 17 19))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
368 ((eq cur-char ?w) ;weekday number, Sunday is 0 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
369 (cdr (assoc (substring time-string 0 3) time-stamp-weekday-numbers))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
370 ((eq cur-char ?y) ;year |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
371 (string-to-int (substring time-string -4))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
372 ((or (eq cur-char ?z) ;time zone |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
373 (eq cur-char ?Z)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
374 (let ((name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
375 (if (fboundp 'current-time-zone) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
376 (car (cdr (current-time-zone time)))))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
377 (or name (setq name "")) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
378 (if (eq cur-char ?z) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
379 (downcase name) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
380 (upcase name)))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
381 ((eq cur-char ?f) ;buffer-file-name, base name only |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
382 (if buffer-file-name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
383 (file-name-nondirectory buffer-file-name) |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
384 time-stamp-no-file)) |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
385 ((eq cur-char ?F) ;buffer-file-name, full path |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
386 (or buffer-file-name |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
387 time-stamp-no-file)) |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
388 ((eq cur-char ?s) ;system name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
389 (system-name)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
390 ((eq cur-char ?u) ;user name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
391 (user-login-name)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
392 ((eq cur-char ?h) ;mail host name |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
393 (time-stamp-mail-host-name)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
394 )) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
395 (if (string-equal field-width "") |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
396 field-result |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
397 (let ((padded-result |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
398 (format (format "%%%s%c" |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
399 field-width |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
400 (if (numberp field-result) ?d ?s)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
401 (or field-result "")))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
402 (let ((initial-length (length padded-result)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
403 (desired-length (string-to-int field-width))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
404 (if (> initial-length desired-length) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
405 ;; truncate strings on right, numbers on left |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
406 (if (stringp field-result) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
407 (substring padded-result 0 desired-length) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
408 (substring padded-result (- desired-length))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
409 padded-result))))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
410 (t |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
411 (char-to-string cur-char))))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
412 (setq ind (1+ ind))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
413 result)) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
414 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
415 (defun time-stamp-mail-host-name () |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
416 "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
|
417 This is the value of `mail-host-address' if bound and a string, |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
418 otherwise the value of `time-stamp-mail-host' (for versions of Emacs |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
419 before 19.29) 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
|
420 (or (and (boundp 'mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
421 (stringp mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
422 mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
423 (and (boundp 'time-stamp-mail-host) ;for backward compatibility |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
424 (stringp time-stamp-mail-host) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
425 time-stamp-mail-host) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
426 (system-name))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
427 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
428 ;;; the rest of this file is for version 1 compatibility |
3854 | 429 |
430 (defun time-stamp-fconcat (list sep) | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
431 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals. |
3854 | 432 If an element of LIST is a symbol, it is funcalled to get the string to use; |
433 the separator SEP is used between two strings obtained by funcalling a | |
434 symbol. Otherwise the element itself is inserted; no separator is used | |
435 around literals." | |
436 (let ((return-string "") | |
437 (insert-sep-p nil)) | |
438 (while list | |
439 (cond ((symbolp (car list)) | |
440 (if insert-sep-p | |
441 (setq return-string (concat return-string sep))) | |
442 (setq return-string (concat return-string (funcall (car list)))) | |
443 (setq insert-sep-p t)) | |
444 (t | |
445 (setq return-string (concat return-string (car list))) | |
446 (setq insert-sep-p nil))) | |
447 (setq list (cdr list))) | |
448 return-string)) | |
449 | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
450 ;;; Some functions used in time-stamp-format |
3854 | 451 |
452 ;;; Could generate most of a message-id with | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
453 ;;; '(time-stamp-yymmdd "" time-stamp-hhmm "@" time-stamp-mail-host-name) |
3854 | 454 |
455 ;;; pretty form, suitable for a title page | |
456 | |
457 (defun time-stamp-month-dd-yyyy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
458 "Return the current date as a string in \"Month DD, YYYY\" form." |
3854 | 459 (let ((date (current-time-string))) |
5287
6811f9d90b62
(time-stamp-month-dd-yyyy): no leading zero on day.
Richard M. Stallman <rms@gnu.org>
parents:
5072
diff
changeset
|
460 (format "%s %d, %s" |
3854 | 461 (aref time-stamp-month-full-names |
462 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))) | |
463 (string-to-int (substring date 8 10)) | |
464 (substring date -4)))) | |
465 | |
16517
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
466 (defun time-stamp-dd/mm/yyyy () |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
467 "Return the current date as a string in \"DD/MM/YYYY\" form." |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
468 (let ((date (current-time-string))) |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
469 (format "%02d/%02d/%s" |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
470 (string-to-int (substring date 8 10)) |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
471 (cdr (assoc (substring date 4 7) time-stamp-month-numbers)) |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
472 (substring date -4) ))) |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
473 |
3854 | 474 ;;; same as __DATE__ in ANSI C |
475 | |
476 (defun time-stamp-mon-dd-yyyy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
477 "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
|
478 The first character of DD is space if the value is less than 10." |
3854 | 479 (let ((date (current-time-string))) |
480 (format "%s %2d %s" | |
481 (substring date 4 7) | |
482 (string-to-int (substring date 8 10)) | |
483 (substring date -4)))) | |
484 | |
485 ;;; RFC 822 date | |
486 | |
487 (defun time-stamp-dd-mon-yy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
488 "Return the current date as a string in \"DD Mon YY\" form." |
3854 | 489 (let ((date (current-time-string))) |
490 (format "%02d %s %s" | |
491 (string-to-int (substring date 8 10)) | |
492 (substring date 4 7) | |
493 (substring date -2)))) | |
494 | |
495 ;;; RCS 3 date | |
496 | |
497 (defun time-stamp-yy/mm/dd () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
498 "Return the current date as a string in \"YY/MM/DD\" form." |
3854 | 499 (let ((date (current-time-string))) |
500 (format "%s/%02d/%02d" | |
501 (substring date -2) | |
502 (cdr (assoc (substring date 4 7) time-stamp-month-numbers)) | |
503 (string-to-int (substring date 8 10))))) | |
504 | |
505 ;;; RCS 5 date | |
506 | |
507 (defun time-stamp-yyyy/mm/dd () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
508 "Return the current date as a string in \"YYYY/MM/DD\" form." |
3854 | 509 (let ((date (current-time-string))) |
510 (format "%s/%02d/%02d" | |
511 (substring date -4) | |
512 (cdr (assoc (substring date 4 7) time-stamp-month-numbers)) | |
513 (string-to-int (substring date 8 10))))) | |
514 | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
515 ;;; ISO 8601 date |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
516 |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
517 (defun time-stamp-yyyy-mm-dd () |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
518 "Return the current date as a string in \"YYYY-MM-DD\" form." |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
519 (let ((date (current-time-string))) |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
520 (format "%s-%02d-%02d" |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
521 (substring date -4) |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
522 (cdr (assoc (substring date 4 7) time-stamp-month-numbers)) |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
523 (string-to-int (substring date 8 10))))) |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
524 |
3854 | 525 (defun time-stamp-yymmdd () |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
526 "Return the current date as a string in \"YYMMDD\" form." |
3854 | 527 (let ((date (current-time-string))) |
528 (format "%s%02d%02d" | |
529 (substring date -2) | |
530 (cdr (assoc (substring date 4 7) time-stamp-month-numbers)) | |
531 (string-to-int (substring date 8 10))))) | |
532 | |
533 (defun time-stamp-hh:mm:ss () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
534 "Return the current time as a string in \"HH:MM:SS\" form." |
3854 | 535 (substring (current-time-string) 11 19)) |
536 | |
537 (defun time-stamp-hhmm () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
538 "Return the current time as a string in \"HHMM\" form." |
3854 | 539 (let ((date (current-time-string))) |
540 (concat (substring date 11 13) | |
541 (substring date 14 16)))) | |
542 | |
543 (provide 'time-stamp) | |
544 | |
545 ;;; time-stamp.el ends here |