Mercurial > emacs
annotate lisp/time-stamp.el @ 17458:eeff371bfe78
(edebug-read-and-maybe-wrap-form): Protect
against pathological recursive calls.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 14 Apr 1997 20:57:39 +0000 |
parents | 368547942e03 |
children | 0dc8180c2e7a |
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 |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
43 ;; $Id: time-stamp.el,v 1.24 1996/12/18 02:45:09 rms Exp rms $ |
3854 | 44 |
45 ;;; Code: | |
46 | |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
47 (defgroup time-stamp nil |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
48 "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
|
49 :group 'data |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
50 :group 'extensions) |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
51 |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
52 (defcustom time-stamp-active t |
13356 | 53 "*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
|
54 Can be toggled by \\[time-stamp-toggle-active]. |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
55 See also the variable `time-stamp-warn-inactive'." |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
56 :type 'boolean |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
57 :group 'time-stamp) |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
58 |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
59 (defcustom time-stamp-warn-inactive t |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
60 "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
|
61 A warning is printed if `time-stamp-active' is nil and the buffer contains |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
62 a time stamp template that would otherwise have been updated." |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
63 :type 'boolean |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
64 :group 'time-stamp) |
3854 | 65 |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
66 (defcustom time-stamp-old-format-warn 'ask |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
67 "Action to take if `time-stamp-format' is an old-style list. |
16674
91590d8f74c3
(time-stamp-am-pm): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
16517
diff
changeset
|
68 If `error', the format is not used. If `ask', the user is queried about |
91590d8f74c3
(time-stamp-am-pm): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
16517
diff
changeset
|
69 using the time-stamp-format. If `warn', a warning is displayed. |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
70 If nil, no notification is given." |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
71 :type '(choice (const :tag "No modification" nil) |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
72 (const :tag "Don't use the format" error) |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
73 (const ask) (const warn)) |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
74 :group 'time-stamp) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
75 |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
76 (defcustom time-stamp-format "%02y/%02m/%02d %02H:%02M:%02S %u" |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
77 "*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
|
78 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
|
79 backward compatibility; see variable `time-stamp-old-format-warn'. |
13356 | 80 |
16674
91590d8f74c3
(time-stamp-am-pm): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
16517
diff
changeset
|
81 A string is used with `format-time-string'. |
13356 | 82 For example, to get the format used by the `date' command, |
16705
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
83 use \"%3a %3b %2d %H:%M:%S %Z %y\". |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
84 |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
85 In addition to the features of `format-time-string', |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
86 you can use the following %-constructs: |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
87 |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
88 %f file name without directory |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
89 %F full file name |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
90 %h mail host name |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
91 %s system name |
17438
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
92 %u user's login name" |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
93 :type 'string |
368547942e03
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16714
diff
changeset
|
94 :group 'time-stamp) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
95 |
3854 | 96 ;;; Do not change time-stamp-line-limit, time-stamp-start, or |
97 ;;; time-stamp-end in your .emacs or you will be incompatible | |
98 ;;; with other people's files! If you must change them, | |
99 ;;; do so only in the local variables section of the file itself. | |
100 | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
101 |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
102 (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
|
103 "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
|
104 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
|
105 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
|
106 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
|
107 |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
108 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
|
109 `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
|
110 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
|
111 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
|
112 |
3854 | 113 |
5971
f97f4938fffa
(time-stamp-start): Allow more white space
Richard M. Stallman <rms@gnu.org>
parents:
5632
diff
changeset
|
114 (defvar time-stamp-start "Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change! |
3854 | 115 "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
|
116 See also the variables `time-stamp-end' and `time-stamp-line-limit'. |
3854 | 117 |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
118 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
|
119 `time-stamp-end' for yourself or you will be incompatible |
3854 | 120 with other people's files! If you must change them for some application, |
121 do so in the local variables section of the time-stamped file itself.") | |
122 | |
123 | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
124 (defvar time-stamp-end "\\\\?[\">]" ;Do not change! |
3854 | 125 "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
|
126 \\[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
|
127 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
|
128 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
|
129 |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
130 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
|
131 `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
|
132 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
|
133 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
|
134 |
3854 | 135 |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
136 |
4327
771786f5d8c2
(time-stamp): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
4325
diff
changeset
|
137 ;;;###autoload |
3854 | 138 (defun time-stamp () |
139 "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
|
140 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
|
141 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
|
142 (add-hook 'write-file-hooks 'time-stamp) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
143 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
|
144 look like one of the following: |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
145 Time-stamp: <> |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
146 Time-stamp: \" \" |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 and `time-stamp-end' control finding the template." |
3854 | 153 (interactive) |
12023
1a3e7aef5f8a
(time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents:
11429
diff
changeset
|
154 (let ((case-fold-search nil) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
155 (start nil) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
156 (end nil) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
157 search-limit) |
12023
1a3e7aef5f8a
(time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents:
11429
diff
changeset
|
158 (save-excursion |
1a3e7aef5f8a
(time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents:
11429
diff
changeset
|
159 (save-restriction |
1a3e7aef5f8a
(time-stamp): only warn about time-stamping
Karl Heuer <kwzh@gnu.org>
parents:
11429
diff
changeset
|
160 (widen) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
161 (cond ((> time-stamp-line-limit 0) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
162 (goto-char (setq start (point-min))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
163 (forward-line time-stamp-line-limit) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
164 (setq search-limit (point))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
165 (t |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
166 (goto-char (setq search-limit (point-max))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
167 (forward-line time-stamp-line-limit) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
168 (setq start (point)))) |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
169 (goto-char start) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
170 (while (and (< (point) search-limit) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
171 (not end) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
172 (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
|
173 (setq start (point)) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
174 (end-of-line) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
175 (let ((line-end (point))) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
176 (goto-char start) |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
177 (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
|
178 (setq end (match-beginning 0))))))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
179 (if end |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
180 (progn |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
181 ;; do all warnings outside save-excursion |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
182 (cond |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
183 ((not time-stamp-active) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
184 (if time-stamp-warn-inactive |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
185 ;; 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
|
186 (progn |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
187 (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
|
188 (sit-for 1)))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
189 ((not (and (stringp time-stamp-start) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
190 (stringp time-stamp-end))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
191 (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
|
192 (sit-for 1)) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
193 (t |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
194 (let ((new-time-stamp (time-stamp-string))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
195 (if (stringp new-time-stamp) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
196 (save-excursion |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
197 (save-restriction |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
198 (widen) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
199 (delete-region start end) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
200 (goto-char start) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
201 (insert new-time-stamp) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
202 (setq end (point)) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
203 ;; 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
|
204 (goto-char start) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
205 (if (search-forward "\t" end t) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
206 (untabify start end))))))))))) |
3854 | 207 ;; be sure to return nil so can be used on write-file-hooks |
208 nil) | |
209 | |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
210 ;;;###autoload |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
211 (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
|
212 "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
|
213 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
|
214 (interactive "P") |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
215 (setq time-stamp-active |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
216 (if (null arg) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
217 (not time-stamp-active) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
218 (> (prefix-numeric-value arg) 0))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
219 (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
|
220 |
16705
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
221 (defconst time-stamp-no-file "(no file)" |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
222 "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
|
223 |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
224 (defun time-stamp-string-preprocess (format) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
225 "Process occurrences in FORMAT of %f, %F, %h, %s and %u. |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
226 These are replaced with the file name (nondirectory part), |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
227 full file name, host name for mail, system name, and user name. |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
228 Do not alter other %-combinations, and do detect %%." |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
229 (let ((result "") (pos 0) (case-fold-search nil) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
230 (file (or buffer-file-name "(no file)"))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
231 (while (string-match "%[%uhfFs]" format pos) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
232 (setq result (concat result (substring format pos (match-beginning 0)))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
233 (let ((char (aref format (1+ (match-beginning 0))))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
234 (cond ((= char ?%) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
235 (setq result (concat result "%%"))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
236 ((= char ?u) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
237 (setq result (concat result (user-login-name)))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
238 ((= char ?f) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
239 (setq result (concat result (file-name-nondirectory file)))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
240 ((= char ?f) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
241 (setq result (concat result file))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
242 ((= char ?s) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
243 (setq result (concat result (system-name)))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
244 ((= char ?h) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
245 (setq result (concat result (time-stamp-mail-host-name)))))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
246 (setq pos (match-end 0))) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
247 (concat result (substring format pos)))) |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
248 |
3854 | 249 (defun time-stamp-string () |
250 "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
|
251 (if (stringp time-stamp-format) |
16705
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
252 (format-time-string (time-stamp-string-preprocess time-stamp-format) |
db8a501954f6
(time-stamp-no-file): Reintroduced.
Richard M. Stallman <rms@gnu.org>
parents:
16674
diff
changeset
|
253 (current-time)) |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
254 ;; handle version 1 compatibility |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
255 (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
|
256 (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
|
257 (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
|
258 (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
|
259 (sit-for 1) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
260 nil) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
261 (t |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
262 (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
|
263 (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
|
264 (sit-for 1))) |
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
265 (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
|
266 |
14042
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
267 (defconst time-stamp-no-file "(no file)" |
161d50568707
(time-stamp-line-limit): negative value counts
Karl Heuer <kwzh@gnu.org>
parents:
13356
diff
changeset
|
268 "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
|
269 |
11404
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
270 (defun time-stamp-mail-host-name () |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
271 "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
|
272 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
|
273 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
|
274 (or (and (boundp 'mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
275 (stringp mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
276 mail-host-address) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
277 (system-name))) |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
278 |
b12a8765508b
(time-stamp-format): Replace list of Lisp
Richard M. Stallman <rms@gnu.org>
parents:
9016
diff
changeset
|
279 ;;; the rest of this file is for version 1 compatibility |
3854 | 280 |
281 (defun time-stamp-fconcat (list sep) | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
282 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals. |
3854 | 283 If an element of LIST is a symbol, it is funcalled to get the string to use; |
284 the separator SEP is used between two strings obtained by funcalling a | |
285 symbol. Otherwise the element itself is inserted; no separator is used | |
286 around literals." | |
287 (let ((return-string "") | |
288 (insert-sep-p nil)) | |
289 (while list | |
290 (cond ((symbolp (car list)) | |
291 (if insert-sep-p | |
292 (setq return-string (concat return-string sep))) | |
293 (setq return-string (concat return-string (funcall (car list)))) | |
294 (setq insert-sep-p t)) | |
295 (t | |
296 (setq return-string (concat return-string (car list))) | |
297 (setq insert-sep-p nil))) | |
298 (setq list (cdr list))) | |
299 return-string)) | |
300 | |
16287
24fd930446f6
(time-stamp-old-format-warn): new variable.
Karl Heuer <kwzh@gnu.org>
parents:
14231
diff
changeset
|
301 ;;; Some functions used in time-stamp-format |
3854 | 302 |
303 ;;; 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
|
304 ;;; '(time-stamp-yymmdd "" time-stamp-hhmm "@" time-stamp-mail-host-name) |
3854 | 305 |
306 ;;; pretty form, suitable for a title page | |
307 | |
308 (defun time-stamp-month-dd-yyyy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
309 "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
|
310 (format-time-string "%B %e, %Y")) |
3854 | 311 |
16517
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
312 (defun time-stamp-dd/mm/yyyy () |
1fa5a347e70f
(time-stamp-dd/mm/yyyy): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16287
diff
changeset
|
313 "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
|
314 (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
|
315 |
3854 | 316 ;;; same as __DATE__ in ANSI C |
317 | |
318 (defun time-stamp-mon-dd-yyyy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
319 "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
|
320 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
|
321 (format-time-string "%b %d %Y")) |
3854 | 322 |
323 ;;; RFC 822 date | |
324 | |
325 (defun time-stamp-dd-mon-yy () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
326 "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
|
327 (format-time-string "%d %b %y")) |
3854 | 328 |
329 ;;; RCS 3 date | |
330 | |
331 (defun time-stamp-yy/mm/dd () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
332 "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
|
333 (format-time-string "%y/%m/%d")) |
3854 | 334 |
335 ;;; RCS 5 date | |
336 | |
337 (defun time-stamp-yyyy/mm/dd () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
338 "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
|
339 (format-time-string "%Y/%m/%d")) |
3854 | 340 |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
341 ;;; ISO 8601 date |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
342 |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
343 (defun time-stamp-yyyy-mm-dd () |
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
344 "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
|
345 (format-time-string "%Y-%m-%d")) |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
346 |
3854 | 347 (defun time-stamp-yymmdd () |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
348 "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
|
349 (format-time-string "%y%m%d")) |
3854 | 350 |
351 (defun time-stamp-hh:mm:ss () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
352 "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
|
353 (format-time-string "%T")) |
3854 | 354 |
355 (defun time-stamp-hhmm () | |
5632
63d80d94e0d7
Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
5287
diff
changeset
|
356 "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
|
357 (format-time-string "%H%M")) |
3854 | 358 |
359 (provide 'time-stamp) | |
360 | |
361 ;;; time-stamp.el ends here |