annotate lisp/time-stamp.el @ 19860:c17fd465ea95 libc-970911 libc-970912 libc-970913 libc-970914 libc-970915 libc-970916 libc-970917 libc-970918 libc-970919 libc-970920 libc-970921 libc-970922 libc-970923 libc-970924 libc-970925 libc-970926 libc-970927 libc-970928 libc-970929 libc-970930 libc-971001 libc-971018 libc-971019 libc-971020 libc-971021 libc-971022 libc-971023 libc-971024 libc-971025 libc-971026 libc-971027 libc-971028 libc-971029 libc-971030 libc-971031 libc-971101 libc-971102 libc-971103 libc-971104 libc-971105 libc-971106 libc-971107 libc-971108 libc-971109 libc-971110 libc-971111 libc-971112 libc-971113 libc-971114 libc-971115 libc-971116 libc-971117 libc-971118 libc-971120 libc-971121 libc-971122 libc-971123 libc-971124 libc-971125 libc-971126 libc-971127 libc-971128 libc-971129 libc-971130 libc-971201 libc-971203 libc-971204 libc-971205 libc-971206 libc-971207 libc-971208 libc-971209 libc-971210 libc-971211 libc-971212 libc-971213 libc-971214 libc-971217 libc-971218 libc-971219 libc-971220 libc-971221 libc-971222 libc-971223 libc-971224 libc-971225 libc-971226 libc-971227 libc-971228 libc-971229 libc-971230 libc-971231 libc-980103 libc-980104 libc-980105 libc-980106 libc-980107 libc-980108 libc-980109 libc-980110 libc-980111 libc-980112 libc-980114 libc-980115 libc-980116 libc-980117 libc-980118 libc-980119 libc-980120 libc-980121 libc-980122 libc-980123 libc-980124 libc-980125 libc-980126 libc-980127 libc-980128

typos.
author Jeff Law <law@redhat.com>
date Wed, 10 Sep 1997 21:16:20 +0000
parents 1366d82c1d3f
children 82e7d581bad1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
3 ;; Copyright 1989, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14042
diff changeset
4
19504
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
5 ;; Maintainer's Time-stamp: <1997-08-07 14:46:50 gildea>
17600
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
6 ;; Maintainer: Stephen Gildea <gildea@alum.mit.edu>
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: tools
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is free software; you can redistribute it and/or modify
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; any later version.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; This file is distributed in the hope that it will be useful,
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14042
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14042
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14042
diff changeset
22 ;; Boston, MA 02111-1307, USA.
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;; Code:
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
17438
368547942e03 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16714
diff changeset
40 (defgroup time-stamp nil
368547942e03 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16714
diff changeset
41 "Maintain last change time stamps in files edited by Emacs."
368547942e03 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16714
diff changeset
42 :group 'data
368547942e03 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16714
diff changeset
43 :group 'extensions)
368547942e03 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16714
diff changeset
44
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
45 (defcustom time-stamp-format "%:y-%02m-%02d %02H:%02M:%02S %u"
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
46 "*Format of the string inserted by \\[time-stamp].
16674
91590d8f74c3 (time-stamp-am-pm): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents: 16517
diff changeset
47 The value may be a string or a list. Lists are supported only for
91590d8f74c3 (time-stamp-am-pm): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents: 16517
diff changeset
48 backward compatibility; see variable `time-stamp-old-format-warn'.
13356
a2a68cba7996 update some doc strings.
Karl Heuer <kwzh@gnu.org>
parents: 12044
diff changeset
49
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
50 A string is used verbatim except for character sequences beginning with %:
16705
db8a501954f6 (time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents: 16674
diff changeset
51
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
52 %:a weekday name: `Monday'. %#A gives uppercase: `MONDAY'
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
53 %3a abbreviated weekday: `Mon'. %3A gives uppercase: `MON'
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
54 %:b month name: `January'. %#B gives uppercase: `JANUARY'
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
55 %3b abbreviated month: `Jan'. %3B gives uppercase: `JAN'
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
56 %02d day of month
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
57 %02H 24-hour clock hour
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
58 %02I 12-hour clock hour
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
59 %02m month number
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
60 %02M minute
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
61 %#p `am' or `pm'. %P gives uppercase: `AM' or `PM'
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
62 %02S seconds
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
63 %w day number of week, Sunday is 0
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
64 %02y 2-digit year: `97' %:y 4-digit year: `1997'
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
65 %z time zone name: `est'. %Z gives uppercase: `EST'
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
66
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
67 Non-date items:
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
68 %% a literal percent character: `%'
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
69 %f file name without directory %F gives absolute pathname
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
70 %s system name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
71 %u user's login name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
72 %h mail host name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
73
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
74 Decimal digits between the % and the type character specify the
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
75 field width. Strings are truncated on the right; years on the left.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
76 A leading zero causes numbers to be zero-filled.
17600
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
77
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
78 For example, to get the format used by the `date' command,
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
79 use \"%3a %3b %2d %02H:%02M:%02S %Z %:y\".
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
80
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
81 In the future these formats will be aligned more with format-time-string.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
82 Because of this transition, the default padding for numeric formats will
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
83 change in a future version. Therefore either a padding width should be
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
84 specified, or the : modifier should be used to explicitly request the
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
85 historical default."
17438
368547942e03 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16714
diff changeset
86 :type 'string
368547942e03 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16714
diff changeset
87 :group 'time-stamp)
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
88
19504
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
89 (defcustom time-stamp-active t
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
90 "*Non-nil to enable time-stamping of buffers by \\[time-stamp].
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
91 Can be toggled by \\[time-stamp-toggle-active].
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
92 See also the variable `time-stamp-warn-inactive'."
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
93 :type 'boolean
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
94 :group 'time-stamp)
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
95
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
96 (defcustom time-stamp-warn-inactive t
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
97 "Non-nil to have \\[time-stamp] warn if a buffer did not get time-stamped.
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
98 A warning is printed if `time-stamp-active' is nil and the buffer contains
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
99 a time stamp template that would otherwise have been updated."
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
100 :type 'boolean
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
101 :group 'time-stamp)
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
102
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
103 (defcustom time-stamp-old-format-warn 'ask
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
104 "Action to take if `time-stamp-format' is an old-style list.
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
105 If `error', the format is not used. If `ask', the user is queried about
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
106 using the time-stamp-format. If `warn', a warning is displayed.
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
107 If nil, no notification is given."
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
108 :type '(choice (const :tag "No notification" nil)
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
109 (const :tag "Don't use the format" error)
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
110 (const ask) (const warn))
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
111 :group 'time-stamp)
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
112
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
113 (defcustom time-stamp-time-zone nil
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
114 "If non-nil, a string naming the timezone to be used by \\[time-stamp].
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
115 Format is the same as that used by the environment variable TZ on your system."
19791
1366d82c1d3f (time-stamp-time-zone): Allow nil as alternative.
Richard M. Stallman <rms@gnu.org>
parents: 19504
diff changeset
116 :type '(choice (const nil) string)
19504
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
117 :group 'time-stamp)
17600
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
118
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
119
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;;; Do not change time-stamp-line-limit, time-stamp-start, or
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;;; time-stamp-end in your .emacs or you will be incompatible
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;;; with other people's files! If you must change them,
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;;; do so only in the local variables section of the file itself.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
125
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
126 (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
127 "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
128 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
129 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
130 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
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
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
5971
f97f4938fffa (time-stamp-start): Allow more white space
Richard M. Stallman <rms@gnu.org>
parents: 5632
diff changeset
138 (defvar time-stamp-start "Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change!
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 "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
140 See also the variables `time-stamp-end' and `time-stamp-line-limit'.
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
142 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
143 `time-stamp-end' for yourself or you will be incompatible
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 with other people's files! If you must change them for some application,
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 do so in the local variables section of the time-stamped file itself.")
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
148 (defvar time-stamp-end "\\\\?[\">]" ;Do not change!
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 "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
150 \\[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
151 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
152 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
153
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
154 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
155 `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
156 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
157 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
158
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
160
4327
771786f5d8c2 (time-stamp): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 4325
diff changeset
161 ;;;###autoload
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (defun time-stamp ()
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 "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
164 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
165 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
166 (add-hook 'write-file-hooks 'time-stamp)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
167 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
168 look like one of the following:
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
169 Time-stamp: <>
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
170 Time-stamp: \" \"
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
171 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
172 Time-stamp: <1996-07-18 10:20:51 gildea>
17600
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
173 The time stamp is updated only if the variable `time-stamp-active' is non-nil.
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
174 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
175 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
176 and `time-stamp-end' control finding the template."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (interactive)
12023
1a3e7aef5f8a (time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents: 11429
diff changeset
178 (let ((case-fold-search nil)
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
179 (start nil)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
180 (end nil)
17600
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
181 search-limit
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
182 (line-limit time-stamp-line-limit))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
183 (cond ((not (integerp line-limit))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
184 (setq line-limit 8)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
185 (message "time-stamp-line-limit is not a number")
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
186 (sit-for 1)))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
187 (save-excursion
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
188 (save-restriction
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
189 (widen)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
190 (cond ((> line-limit 0)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
191 (goto-char (setq start (point-min)))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
192 (forward-line line-limit)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
193 (setq search-limit (point)))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
194 (t
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
195 (goto-char (setq search-limit (point-max)))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
196 (forward-line line-limit)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
197 (setq start (point))))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
198 (goto-char start)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
199 (while (and (< (point) search-limit)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
200 (not end)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
201 (re-search-forward time-stamp-start search-limit 'move))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
202 (setq start (point))
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
203 (end-of-line)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
204 (let ((line-end (point)))
14042
161d50568707 (time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents: 13356
diff changeset
205 (goto-char start)
17600
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
206 (if (re-search-forward time-stamp-end line-end 'move)
0dc8180c2e7a (time-stamp-old-format-warn): Fix a tag string.
Richard M. Stallman <rms@gnu.org>
parents: 17438
diff changeset
207 (setq end (match-beginning 0)))))))
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
208 (if end
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
209 (progn
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
210 ;; do all warnings outside save-excursion
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
211 (cond
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
212 ((not time-stamp-active)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
213 (if time-stamp-warn-inactive
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
214 ;; 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
215 (progn
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
216 (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
217 (sit-for 1))))
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
218 ((not (and (stringp time-stamp-start)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
219 (stringp time-stamp-end)))
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
220 (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
221 (sit-for 1))
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
222 (t
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
223 (let ((new-time-stamp (time-stamp-string)))
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
224 (if (stringp new-time-stamp)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
225 (save-excursion
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
226 (save-restriction
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
227 (widen)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
228 (delete-region start end)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
229 (goto-char start)
19154
57f551ebd40b (time-stamp): Use insert-and-inherit for new stamp.
Richard M. Stallman <rms@gnu.org>
parents: 18171
diff changeset
230 (insert-and-inherit new-time-stamp)
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
231 (setq end (point))
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
232 ;; 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
233 (goto-char start)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
234 (if (search-forward "\t" end t)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
235 (untabify start end)))))))))))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 ;; be sure to return nil so can be used on write-file-hooks
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 nil)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
11404
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
239 ;;;###autoload
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
240 (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
241 "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
242 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
243 (interactive "P")
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
244 (setq time-stamp-active
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
245 (if (null arg)
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
246 (not time-stamp-active)
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
247 (> (prefix-numeric-value arg) 0)))
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
248 (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
249
16705
db8a501954f6 (time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents: 16674
diff changeset
250 (defconst time-stamp-no-file "(no file)"
db8a501954f6 (time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents: 16674
diff changeset
251 "String to use when the buffer is not associated with a file.")
db8a501954f6 (time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents: 16674
diff changeset
252
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
253 ;;; time-stamp is transitioning to using the new, expanded capabilities
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
254 ;;; of format-time-string. During the process, this function implements
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
255 ;;; intermediate, compatible formats and complains about old, soon to
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
256 ;;; be unsupported, formats. This function will get a lot (a LOT) shorter
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
257 ;;; when the transition is complete and we can just pass most things
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
258 ;;; straight through to format-time-string.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
259 ;;; At all times, all the formats recommended in the doc string
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
260 ;;; of time-stamp-format will work not only in the current version of
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
261 ;;; Emacs, but in all versions that have been released within the past
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
262 ;;; two years.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
263 ;;; The : modifier is a temporary conversion feature used to resolve
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
264 ;;; ambiguous formats--formats that are changing (over time) incompatibly.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
265 (defun time-stamp-string-preprocess (format &optional time)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
266 ;; Uses a FORMAT to format date, time, file, and user information.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
267 ;; Optional second argument TIME is only for testing.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
268 ;; Implements non-time extensions to format-time-string
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
269 ;; and all time-stamp-format compatibility.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
270 (let ((fmt-len (length format))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
271 (ind 0)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
272 cur-char
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
273 (prev-char nil)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
274 (result "")
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
275 field-index
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
276 field-width
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
277 field-result
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
278 alt-form change-case require-padding
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
279 (paren-level 0))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
280 (while (< ind fmt-len)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
281 (setq cur-char (aref format ind))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
282 (setq
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
283 result
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
284 (concat result
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
285 (cond
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
286 ((eq cur-char ?%)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
287 ;; eat any additional args to allow for future expansion
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
288 (setq alt-form nil change-case nil require-padding nil)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
289 (while (progn
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
290 (setq ind (1+ ind))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
291 (setq cur-char (if (< ind fmt-len)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
292 (aref format ind)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
293 ?\0))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
294 (or (eq ?. cur-char)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
295 (eq ?, cur-char) (eq ?: cur-char) (eq ?@ cur-char)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
296 (eq ?- cur-char) (eq ?+ cur-char) (eq ?_ cur-char)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
297 (eq ?\ cur-char) (eq ?# cur-char) (eq ?^ cur-char)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
298 (and (eq ?\( cur-char)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
299 (not (eq prev-char ?\\))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
300 (setq paren-level (1+ paren-level)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
301 (if (and (eq ?\) cur-char)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
302 (not (eq prev-char ?\\))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
303 (> paren-level 0))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
304 (setq paren-level (1- paren-level))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
305 (and (> paren-level 0)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
306 (< ind fmt-len)))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
307 (setq prev-char cur-char)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
308 ;; some characters we actually use
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
309 (cond ((eq cur-char ?:)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
310 (setq alt-form t))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
311 ((eq cur-char ?#)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
312 (setq change-case t))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
313 ;; get format width
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
314 (setq field-index ind)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
315 (setq ind (1- ind))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
316 (while (progn
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
317 (setq ind (1+ ind))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
318 (setq cur-char (if (< ind fmt-len)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
319 (aref format ind)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
320 ?\0))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
321 (and (<= ?0 cur-char) (>= ?9 cur-char))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
322 (setq field-width (substring format field-index ind))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
323 (setq field-result
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
324 (cond
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
325 ((eq cur-char ?%)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
326 "%")
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
327 ((eq cur-char ?a) ;day of week
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
328 (if change-case
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
329 (format-time-string "%#A" time)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
330 (or alt-form (not (string-equal field-width ""))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
331 (time-stamp-conv-warn "%a" "%:a"))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
332 (if (and alt-form (not (string-equal field-width "")))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
333 "" ;discourage "%:3a"
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
334 (format-time-string "%A" time))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
335 ((eq cur-char ?A)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
336 (if alt-form
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
337 (format-time-string "%A" time)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
338 (or change-case (not (string-equal field-width ""))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
339 (time-stamp-conv-warn "%A" "%#A"))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
340 (format-time-string "%#A" time)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
341 ((eq cur-char ?b) ;month name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
342 (if change-case
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
343 (format-time-string "%#B" time)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
344 (or alt-form (not (string-equal field-width ""))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
345 (time-stamp-conv-warn "%b" "%:b"))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
346 (if (and alt-form (not (string-equal field-width "")))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
347 "" ;discourage "%:3b"
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
348 (format-time-string "%B" time))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
349 ((eq cur-char ?B)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
350 (if alt-form
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
351 (format-time-string "%B" time)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
352 (or change-case (not (string-equal field-width ""))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
353 (time-stamp-conv-warn "%B" "%#B"))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
354 (format-time-string "%#B" time)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
355 ((eq cur-char ?d) ;day of month, 1-31
18171
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
356 (time-stamp-do-number cur-char alt-form field-width time))
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
357 ((eq cur-char ?H) ;hour, 0-23
18171
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
358 (time-stamp-do-number cur-char alt-form field-width time))
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
359 ((eq cur-char ?I) ;hour, 1-12
18171
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
360 (time-stamp-do-number cur-char alt-form field-width time))
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
361 ((eq cur-char ?m) ;month number, 1-12
18171
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
362 (time-stamp-do-number cur-char alt-form field-width time))
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
363 ((eq cur-char ?M) ;minute, 0-59
18171
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
364 (time-stamp-do-number cur-char alt-form field-width time))
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
365 ((eq cur-char ?p) ;am or pm
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
366 (or change-case
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
367 (time-stamp-conv-warn "%p" "%#p"))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
368 (format-time-string "%#p" time))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
369 ((eq cur-char ?P) ;AM or PM
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
370 (format-time-string "%p" time))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
371 ((eq cur-char ?S) ;seconds, 00-60
18171
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
372 (time-stamp-do-number cur-char alt-form field-width time))
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
373 ((eq cur-char ?w) ;weekday number, Sunday is 0
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
374 (format-time-string "%w" time))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
375 ((eq cur-char ?y) ;year
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
376 (or alt-form (not (string-equal field-width ""))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
377 (time-stamp-conv-warn "%y" "%:y"))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
378 (string-to-int (format-time-string "%Y" time)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
379 ((eq cur-char ?Y) ;4-digit year, new style
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
380 (string-to-int (format-time-string "%Y" time)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
381 ((eq cur-char ?z) ;time zone lower case
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
382 (if change-case
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
383 "" ;discourage %z variations
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
384 (format-time-string "%#Z" time)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
385 ((eq cur-char ?Z)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
386 (if change-case
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
387 (format-time-string "%#Z" time)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
388 (format-time-string "%Z" time)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
389 ((eq cur-char ?f) ;buffer-file-name, base name only
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
390 (if buffer-file-name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
391 (file-name-nondirectory buffer-file-name)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
392 time-stamp-no-file))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
393 ((eq cur-char ?F) ;buffer-file-name, full path
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
394 (or buffer-file-name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
395 time-stamp-no-file))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
396 ((eq cur-char ?s) ;system name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
397 (system-name))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
398 ((eq cur-char ?u) ;user name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
399 (user-login-name))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
400 ((eq cur-char ?h) ;mail host name
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
401 (time-stamp-mail-host-name))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
402 ))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
403 (if (string-equal field-width "")
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
404 field-result
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
405 (let ((padded-result
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
406 (format (format "%%%s%c"
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
407 field-width
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
408 (if (numberp field-result) ?d ?s))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
409 (or field-result ""))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
410 (let ((initial-length (length padded-result))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
411 (desired-length (string-to-int field-width)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
412 (if (> initial-length desired-length)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
413 ;; truncate strings on right, years on left
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
414 (if (stringp field-result)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
415 (substring padded-result 0 desired-length)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
416 (if (eq cur-char ?y)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
417 (substring padded-result (- desired-length))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
418 padded-result)) ;non-year numbers don't truncate
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
419 padded-result)))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
420 (t
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
421 (char-to-string cur-char)))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
422 (setq ind (1+ ind)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
423 result))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
424
18171
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
425 (defun time-stamp-do-number (format-char alt-form field-width time)
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
426 ;; Handle a compatible FORMAT-CHAR where only
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
427 ;; the default width/padding will change.
18171
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
428 ;; ALT-FORM is whether `#' specified. FIELD-WIDTH is the string
566b6cf773ed (time-stamp-string-preprocess, time-stamp-do-number):
Richard M. Stallman <rms@gnu.org>
parents: 18170
diff changeset
429 ;; width specification or "". TIME is the time to convert.
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
430 (let ((format-string (concat "%" (char-to-string format-char))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
431 (and (not alt-form) (string-equal field-width "")
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
432 (time-stamp-conv-warn format-string
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
433 (format "%%:%c" format-char)))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
434 (if (and alt-form (not (string-equal field-width "")))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
435 "" ;discourage "%:2d" and the like
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
436 (string-to-int (format-time-string format-string time)))))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
437
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
438 (defvar time-stamp-conversion-warn t
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
439 "Non-nil to warn about soon-to-be-unsupported forms in time-stamp-format.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
440 In would be a bad idea to disable these warnings!
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
441 You really need to update your files instead.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
442
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
443 The new formats will work with old versions of Emacs.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
444 New formats are being recommended now to allow time-stamp-format
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
445 to change in the future to be compatible with format-time-string.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
446 The new forms being recommended now will continue to work then.")
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
447
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
448
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
449 (defun time-stamp-conv-warn (old-form new-form)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
450 ;; Display a warning about a soon-to-be-obsolete format.
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
451 (cond
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
452 (time-stamp-conversion-warn
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
453 (save-excursion
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
454 (set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
455 (goto-char (point-max))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
456 (if (bobp)
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
457 (progn
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
458 (insert
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
459 "The formats recognized in time-stamp-format will change in a future release\n"
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
460 "to be compatible with the new, expanded format-time-string function.\n\n"
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
461 "The following obsolescent time-stamp-format construct(s) were found:\n\n")))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
462 (insert "\"" old-form "\" -- use " new-form "\n"))
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
463 (display-buffer "*Time-stamp-compatibility*"))))
19504
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
464
18170
7776ee6215de (time-stamp-format): Doc fix. Use %;y.
Richard M. Stallman <rms@gnu.org>
parents: 17600
diff changeset
465
11404
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
466
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (defun time-stamp-string ()
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 "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
469 (if (stringp time-stamp-format)
19504
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
470 (if (stringp time-stamp-time-zone)
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
471 (let ((real-time-zone (getenv "TZ")))
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
472 (unwind-protect
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
473 (progn
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
474 (setenv "TZ" time-stamp-time-zone)
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
475 (format-time-string
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
476 (time-stamp-string-preprocess time-stamp-format)))
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
477 (setenv "TZ" real-time-zone)))
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
478 (format-time-string
fd1ee3c25839 (time-stamp-time-zone): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19154
diff changeset
479 (time-stamp-string-preprocess time-stamp-format)))
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
480 ;; handle version 1 compatibility
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
481 (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
482 (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
483 (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
484 (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
485 (sit-for 1)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
486 nil)
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
487 (t
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
488 (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
489 (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
490 (sit-for 1)))
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
491 (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
492
14042
161d50568707 (time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents: 13356
diff changeset
493 (defconst time-stamp-no-file "(no file)"
161d50568707 (time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents: 13356
diff changeset
494 "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
495
11404
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
496 (defun time-stamp-mail-host-name ()
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
497 "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
498 This is the value of `mail-host-address' if bound and a string,
16714
634b34517d56 (time-stamp-mail-host-name): Get rid of time-stamp-mail-host.
Richard M. Stallman <rms@gnu.org>
parents: 16706
diff changeset
499 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
500 (or (and (boundp 'mail-host-address)
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
501 (stringp mail-host-address)
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
502 mail-host-address)
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
503 (system-name)))
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
504
b12a8765508b (time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents: 9016
diff changeset
505 ;;; the rest of this file is for version 1 compatibility
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (defun time-stamp-fconcat (list sep)
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
508 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals.
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 If an element of LIST is a symbol, it is funcalled to get the string to use;
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 the separator SEP is used between two strings obtained by funcalling a
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 symbol. Otherwise the element itself is inserted; no separator is used
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 around literals."
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (let ((return-string "")
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (insert-sep-p nil))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (while list
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (cond ((symbolp (car list))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (if insert-sep-p
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (setq return-string (concat return-string sep)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (setq return-string (concat return-string (funcall (car list))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 (setq insert-sep-p t))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (t
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 (setq return-string (concat return-string (car list)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (setq insert-sep-p nil)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (setq list (cdr list)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 return-string))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526
16287
24fd930446f6 (time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents: 14231
diff changeset
527 ;;; Some functions used in time-stamp-format
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 ;;; 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
530 ;;; '(time-stamp-yymmdd "" time-stamp-hhmm "@" time-stamp-mail-host-name)
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 ;;; pretty form, suitable for a title page
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (defun time-stamp-month-dd-yyyy ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
535 "Return the current date as a string in \"Month DD, YYYY\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
536 (format-time-string "%B %e, %Y"))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537
16517
1fa5a347e70f (time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16287
diff changeset
538 (defun time-stamp-dd/mm/yyyy ()
1fa5a347e70f (time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16287
diff changeset
539 "Return the current date as a string in \"DD/MM/YYYY\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
540 (format-time-string "%d/%m/%Y"))
16517
1fa5a347e70f (time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16287
diff changeset
541
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 ;;; same as __DATE__ in ANSI C
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (defun time-stamp-mon-dd-yyyy ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
545 "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
546 The first character of DD is space if the value is less than 10."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
547 (format-time-string "%b %d %Y"))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 ;;; RFC 822 date
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (defun time-stamp-dd-mon-yy ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
552 "Return the current date as a string in \"DD Mon YY\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
553 (format-time-string "%d %b %y"))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 ;;; RCS 3 date
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (defun time-stamp-yy/mm/dd ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
558 "Return the current date as a string in \"YY/MM/DD\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
559 (format-time-string "%y/%m/%d"))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 ;;; RCS 5 date
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (defun time-stamp-yyyy/mm/dd ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
564 "Return the current date as a string in \"YYYY/MM/DD\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
565 (format-time-string "%Y/%m/%d"))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
567 ;;; ISO 8601 date
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
568
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
569 (defun time-stamp-yyyy-mm-dd ()
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
570 "Return the current date as a string in \"YYYY-MM-DD\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
571 (format-time-string "%Y-%m-%d"))
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
572
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (defun time-stamp-yymmdd ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
574 "Return the current date as a string in \"YYMMDD\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
575 (format-time-string "%y%m%d"))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (defun time-stamp-hh:mm:ss ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
578 "Return the current time as a string in \"HH:MM:SS\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
579 (format-time-string "%T"))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (defun time-stamp-hhmm ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
582 "Return the current time as a string in \"HHMM\" form."
16706
450cb7cbf895 (time-stamp-month-dd-yyyy): Use format-time-string.
Richard M. Stallman <rms@gnu.org>
parents: 16705
diff changeset
583 (format-time-string "%H%M"))
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (provide 'time-stamp)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 ;;; time-stamp.el ends here