time-stamp: refactor for readability
* lisp/time-stamp.el (time-stamp-string-preprocess): Move all of the big 'while' loop to the end of the function, to better expose its structure of iterating over the format string.
This commit is contained in:
parent
26f5e6339b
commit
1bfbaacc05
1 changed files with 18 additions and 13 deletions
|
@ -531,18 +531,13 @@ time is used. The time zone is determined by `time-stamp-time-zone'."
|
|||
Optional second argument TIME is only for testing.
|
||||
This is an internal routine implementing extensions to `format-time-string'
|
||||
and all `time-stamp-format' compatibility."
|
||||
(let ((fmt-len (length format))
|
||||
(ind 0)
|
||||
cur-char
|
||||
(result ""))
|
||||
(while (< ind fmt-len)
|
||||
(setq cur-char (aref format ind))
|
||||
(setq
|
||||
result
|
||||
(concat
|
||||
result
|
||||
(cond
|
||||
((eq cur-char ?%)
|
||||
(let*
|
||||
((fmt-len (length format))
|
||||
(ind 0)
|
||||
cur-char
|
||||
(result "")
|
||||
(handle-one-conversion
|
||||
(lambda ()
|
||||
(let ((prev-char nil)
|
||||
(field-width "")
|
||||
field-result
|
||||
|
@ -780,7 +775,17 @@ and all `time-stamp-format' compatibility."
|
|||
(format (format "%%%s%c"
|
||||
field-width
|
||||
(if (numberp field-result) ?d ?s))
|
||||
(or field-result ""))))
|
||||
(or field-result "")))))) ;end of handle-one-conversion
|
||||
;; iterate over the format string
|
||||
(while (< ind fmt-len)
|
||||
(setq cur-char (aref format ind))
|
||||
(setq
|
||||
result
|
||||
(concat
|
||||
result
|
||||
(cond
|
||||
((eq cur-char ?%)
|
||||
(funcall handle-one-conversion))
|
||||
(t
|
||||
(char-to-string cur-char)))))
|
||||
(setq ind (1+ ind)))
|
||||
|
|
Loading…
Add table
Reference in a new issue