comparison lisp/time-stamp.el @ 22508:c9307c229265

(time-stamp): Handle newlines in time-stamp-pattern. (time-stamp-string-preprocess): Handle more than one numeric arg.
author Karl Heuer <kwzh@gnu.org>
date Fri, 19 Jun 1998 16:50:37 +0000
parents 82e7d581bad1
children f580b9694876
comparison
equal deleted inserted replaced
22507:f189183483a2 22508:c9307c229265
214 (ts-start time-stamp-start) 214 (ts-start time-stamp-start)
215 (ts-format time-stamp-format) 215 (ts-format time-stamp-format)
216 (ts-end time-stamp-end)) 216 (ts-end time-stamp-end))
217 (if (stringp time-stamp-pattern) 217 (if (stringp time-stamp-pattern)
218 (progn 218 (progn
219 (string-match "^\\(\\(-?[0-9]+\\)/\\)?\\([^%]+\\)?\\(.*%[-.,:@+_ #^()0-9]*[A-Za-z%]\\)?\\([^%]+\\)?$" time-stamp-pattern) 219 (string-match "\\`\\(\\(-?[0-9]+\\)/\\)?\\([^%]+\\)?\\(\\(.\\|\n\\)*%[-.,:@+_ #^()0-9]*[A-Za-z%]\\)?\\([^%]+\\)?\\'" time-stamp-pattern)
220 (and (match-beginning 2) 220 (and (match-beginning 2)
221 (setq line-limit 221 (setq line-limit
222 (string-to-int (match-string 2 time-stamp-pattern)))) 222 (string-to-int (match-string 2 time-stamp-pattern))))
223 (and (match-beginning 3) 223 (and (match-beginning 3)
224 (setq ts-start (match-string 3 time-stamp-pattern))) 224 (setq ts-start (match-string 3 time-stamp-pattern)))
225 (and (match-beginning 4) 225 (and (match-beginning 4)
226 (not (string-equal (match-string 4 time-stamp-pattern) "%%")) 226 (not (string-equal (match-string 4 time-stamp-pattern) "%%"))
227 (setq ts-format (match-string 4 time-stamp-pattern))) 227 (setq ts-format (match-string 4 time-stamp-pattern)))
228 (and (match-beginning 5) 228 (and (match-beginning 6)
229 (setq ts-end (match-string 5 time-stamp-pattern))))) 229 (setq ts-end (match-string 6 time-stamp-pattern)))))
230 (cond ((not (integerp line-limit)) 230 (cond ((not (integerp line-limit))
231 (setq line-limit 8) 231 (setq line-limit 8)
232 (message "time-stamp-line-limit is not an integer") 232 (message "time-stamp-line-limit is not an integer")
233 (sit-for 1))) 233 (sit-for 1)))
234 (save-excursion 234 (save-excursion
317 (let ((fmt-len (length format)) 317 (let ((fmt-len (length format))
318 (ind 0) 318 (ind 0)
319 cur-char 319 cur-char
320 (prev-char nil) 320 (prev-char nil)
321 (result "") 321 (result "")
322 field-index
323 field-width 322 field-width
324 field-result 323 field-result
325 alt-form change-case require-padding 324 alt-form change-case require-padding
326 (paren-level 0)) 325 (paren-level 0))
327 (while (< ind fmt-len) 326 (while (< ind fmt-len)
330 result 329 result
331 (concat result 330 (concat result
332 (cond 331 (cond
333 ((eq cur-char ?%) 332 ((eq cur-char ?%)
334 ;; eat any additional args to allow for future expansion 333 ;; eat any additional args to allow for future expansion
335 (setq alt-form nil change-case nil require-padding nil) 334 (setq alt-form nil change-case nil require-padding nil field-width "")
336 (while (progn 335 (while (progn
337 (setq ind (1+ ind)) 336 (setq ind (1+ ind))
338 (setq cur-char (if (< ind fmt-len) 337 (setq cur-char (if (< ind fmt-len)
339 (aref format ind) 338 (aref format ind)
340 ?\0)) 339 ?\0))
348 (if (and (eq ?\) cur-char) 347 (if (and (eq ?\) cur-char)
349 (not (eq prev-char ?\\)) 348 (not (eq prev-char ?\\))
350 (> paren-level 0)) 349 (> paren-level 0))
351 (setq paren-level (1- paren-level)) 350 (setq paren-level (1- paren-level))
352 (and (> paren-level 0) 351 (and (> paren-level 0)
353 (< ind fmt-len))))) 352 (< ind fmt-len)))
353 (if (and (<= ?0 cur-char) (>= ?9 cur-char))
354 ;; get format width
355 (let ((field-index ind))
356 (while (progn
357 (setq ind (1+ ind))
358 (setq cur-char (if (< ind fmt-len)
359 (aref format ind)
360 ?\0))
361 (and (<= ?0 cur-char) (>= ?9 cur-char))))
362 (setq field-width (substring format field-index ind))
363 (setq ind (1- ind))
364 t))))
354 (setq prev-char cur-char) 365 (setq prev-char cur-char)
355 ;; some characters we actually use 366 ;; some characters we actually use
356 (cond ((eq cur-char ?:) 367 (cond ((eq cur-char ?:)
357 (setq alt-form t)) 368 (setq alt-form t))
358 ((eq cur-char ?#) 369 ((eq cur-char ?#)
359 (setq change-case t)))) 370 (setq change-case t))))
360 ;; get format width
361 (setq field-index ind)
362 (setq ind (1- ind))
363 (while (progn
364 (setq ind (1+ ind))
365 (setq cur-char (if (< ind fmt-len)
366 (aref format ind)
367 ?\0))
368 (and (<= ?0 cur-char) (>= ?9 cur-char))))
369 (setq field-width (substring format field-index ind))
370 (setq field-result 371 (setq field-result
371 (cond 372 (cond
372 ((eq cur-char ?%) 373 ((eq cur-char ?%)
373 "%") 374 "%")
374 ((eq cur-char ?a) ;day of week 375 ((eq cur-char ?a) ;day of week