Function: time-stamp-once
time-stamp-once is a byte-compiled function defined in
time-stamp.el.gz.
Signature
(time-stamp-once START SEARCH-LIMIT TS-START TS-END TS-FORMAT FORMAT-LINES END-LINES)
Documentation
Update one time stamp. Internal routine called by M-x time-stamp (time-stamp).
Returns the end point, which is where time-stamp begins the next search.
Source Code
;; Defined in /usr/src/emacs/lisp/time-stamp.el.gz
(defun time-stamp-once (start search-limit ts-start ts-end
ts-format format-lines end-lines)
"Update one time stamp. Internal routine called by \\[time-stamp].
Returns the end point, which is where `time-stamp' begins the next search."
(let ((case-fold-search nil)
(end nil)
end-search-start
(end-length nil))
(save-excursion
(save-restriction
(widen)
;; Find the location of the time stamp.
(while (and (< (goto-char start) search-limit)
(not end)
(re-search-forward ts-start search-limit 'move))
(setq start (point))
(if (not time-stamp-inserts-lines)
(forward-line format-lines))
(setq end-search-start (max start (point)))
(if (= (forward-line end-lines) 0)
(progn
(and (bolp) (backward-char))
(let ((line-end (min (point) search-limit)))
(if (>= line-end end-search-start)
(progn
(goto-char end-search-start)
(if (re-search-forward ts-end line-end t)
(progn
(setq end (match-beginning 0))
(setq end-length (- (match-end 0) end))))))))))))
(if end
(progn
;; do all warnings outside save-excursion
(cond
((not time-stamp-active)
(if time-stamp-warn-inactive
;; don't signal an error in a write-file-hook
(progn
(message "Warning: time-stamp-active is off; did not time-stamp buffer.")
(sit-for 1))))
((not (and (stringp ts-start)
(stringp ts-end)))
(message "time-stamp-start or time-stamp-end is not a string")
(sit-for 1))
(t
(let ((new-time-stamp (time-stamp-string ts-format)))
(if (and (stringp new-time-stamp)
(not (string-equal (buffer-substring start end)
new-time-stamp)))
(save-excursion
(save-restriction
(widen)
(delete-region start end)
(goto-char start)
(insert-and-inherit new-time-stamp)
(setq end (point))
;; remove any tabs used to format time stamp
(if (search-backward "\t" start t)
(progn
(untabify start end)
(setq end (point))))))))))))
;; return the location after this time stamp, if there was one
(and end end-length
(+ end end-length))))