comparison lisp/time-stamp.el @ 24266:894911d2c01d

(time-stamp-format): Format doc tighter. (time-stamp-line-limit): 0 searches the entire buffer (careful!). (time-stamp): don't re-write the time stamp if it didn't change.
author Richard M. Stallman <rms@gnu.org>
date Sat, 06 Feb 1999 05:00:54 +0000
parents f580b9694876
children 456e2e2bc4d3
comparison
equal deleted inserted replaced
24265:c5f1a1deffbb 24266:894911d2c01d
1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs 1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
2 2
3 ;; Copyright 1989, 1993, 1994, 1995, 1997 Free Software Foundation, Inc. 3 ;; Copyright 1989, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
4 4
5 ;; Maintainer's Time-stamp: <1998-03-04 14:14:19 gildea> 5 ;; Maintainer's Time-stamp: <1999-01-06 11:06:03 gildea>
6 ;; Maintainer: Stephen Gildea <gildea@alum.mit.edu> 6 ;; Maintainer: Stephen Gildea <gildea@alum.mit.edu>
7 ;; Keywords: tools 7 ;; Keywords: tools
8 8
9 ;; This file is free software; you can redistribute it and/or modify 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 10 ;; it under the terms of the GNU General Public License as published by
66 66
67 Non-date items: 67 Non-date items:
68 %% a literal percent character: `%' 68 %% a literal percent character: `%'
69 %f file name without directory %F gives absolute pathname 69 %f file name without directory %F gives absolute pathname
70 %s system name 70 %s system name
71 %u user's login name 71 %u user's login name %U user's full name
72 %U user's full name
73 %h mail host name 72 %h mail host name
74 73
75 Decimal digits between the % and the type character specify the 74 Decimal digits between the % and the type character specify the
76 field width. Strings are truncated on the right; years on the left. 75 field width. Strings are truncated on the right; years on the left.
77 A leading zero causes numbers to be zero-filled. 76 A leading zero causes numbers to be zero-filled.
127 126
128 (defvar time-stamp-line-limit 8 ;Do not change! 127 (defvar time-stamp-line-limit 8 ;Do not change!
129 "Lines of a file searched; positive counts from start, negative from end. 128 "Lines of a file searched; positive counts from start, negative from end.
130 The patterns `time-stamp-start' and `time-stamp-end' must be found on one 129 The patterns `time-stamp-start' and `time-stamp-end' must be found on one
131 of the first (last) `time-stamp-line-limit' lines of the file for the 130 of the first (last) `time-stamp-line-limit' lines of the file for the
132 file to be time-stamped by \\[time-stamp]. 131 file to be time-stamped by \\[time-stamp]. A value of 0 searches the
132 entire buffer (use with care).
133 133
134 Do not change `time-stamp-line-limit', `time-stamp-start', or 134 Do not change `time-stamp-line-limit', `time-stamp-start', or
135 `time-stamp-end' for yourself or you will be incompatible 135 `time-stamp-end' for yourself or you will be incompatible
136 with other people's files! If you must change them for some application, 136 with other people's files! If you must change them for some application,
137 do so in the local variables section of the time-stamped file itself.") 137 do so in the local variables section of the time-stamped file itself.")
237 (widen) 237 (widen)
238 (cond ((> line-limit 0) 238 (cond ((> line-limit 0)
239 (goto-char (setq start (point-min))) 239 (goto-char (setq start (point-min)))
240 (forward-line line-limit) 240 (forward-line line-limit)
241 (setq search-limit (point))) 241 (setq search-limit (point)))
242 (t 242 ((< line-limit 0)
243 (goto-char (setq search-limit (point-max))) 243 (goto-char (setq search-limit (point-max)))
244 (forward-line line-limit) 244 (forward-line line-limit)
245 (setq start (point)))) 245 (setq start (point)))
246 (t ;0 => no limit (use with care!)
247 (setq start (point-min))
248 (setq search-limit (point-max))))
246 (goto-char start) 249 (goto-char start)
247 (while (and (< (point) search-limit) 250 (while (and (< (point) search-limit)
248 (not end) 251 (not end)
249 (re-search-forward ts-start search-limit 'move)) 252 (re-search-forward ts-start search-limit 'move))
250 (setq start (point)) 253 (setq start (point))
267 (stringp ts-end))) 270 (stringp ts-end)))
268 (message "time-stamp-start or time-stamp-end is not a string") 271 (message "time-stamp-start or time-stamp-end is not a string")
269 (sit-for 1)) 272 (sit-for 1))
270 (t 273 (t
271 (let ((new-time-stamp (time-stamp-string ts-format))) 274 (let ((new-time-stamp (time-stamp-string ts-format)))
272 (if (stringp new-time-stamp) 275 (if (and (stringp new-time-stamp)
276 (not (string-equal (buffer-substring start end)
277 new-time-stamp)))
273 (save-excursion 278 (save-excursion
274 (save-restriction 279 (save-restriction
275 (widen) 280 (widen)
276 (delete-region start end) 281 (delete-region start end)
277 (goto-char start) 282 (goto-char start)