Function: dotimes-with-progress-reporter
dotimes-with-progress-reporter is a macro defined in subr.el.gz.
Signature
(dotimes-with-progress-reporter (VAR COUNT [RESULT]) REPORTER-OR-MESSAGE BODY...)
Documentation
Loop a certain number of times and report progress in the echo area.
Evaluate BODY with VAR bound to successive integers running from
0, inclusive, to COUNT, exclusive. Then evaluate RESULT to get
the return value (nil if RESULT is omitted).
REPORTER-OR-MESSAGE is a progress reporter object or a string. In the latter case, use this string to create a progress reporter.
At each iteration, print the reporter message followed by progress percentage in the echo area. After the loop is finished, print the reporter message followed by the word "done".
This macro is a convenience wrapper around make-progress-reporter and friends.
Probably introduced at or before Emacs version 22.1.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body)
"Loop a certain number of times and report progress in the echo area.
Evaluate BODY with VAR bound to successive integers running from
0, inclusive, to COUNT, exclusive. Then evaluate RESULT to get
the return value (nil if RESULT is omitted).
REPORTER-OR-MESSAGE is a progress reporter object or a string. In the latter
case, use this string to create a progress reporter.
At each iteration, print the reporter message followed by progress
percentage in the echo area. After the loop is finished,
print the reporter message followed by the word \"done\".
This macro is a convenience wrapper around `make-progress-reporter' and friends.
\(fn (VAR COUNT [RESULT]) REPORTER-OR-MESSAGE BODY...)"
(declare (indent 2) (debug ((symbolp form &optional form) form body)))
(let ((prep (make-symbol "--dotimes-prep--"))
(end (make-symbol "--dotimes-end--")))
`(let ((,prep ,reporter-or-message)
(,end ,(cadr spec)))
(when (stringp ,prep)
(setq ,prep (make-progress-reporter ,prep 0 ,end)))
(dotimes (,(car spec) ,end)
,@body
(progress-reporter-update ,prep (1+ ,(car spec))))
(progress-reporter-done ,prep)
(or ,@(cdr (cdr spec)) nil))))