Skip to content

Instantly share code, notes, and snippets.

@legoscia
Created January 8, 2015 15:25
Show Gist options
  • Save legoscia/931322eaa70c8927821c to your computer and use it in GitHub Desktop.
Save legoscia/931322eaa70c8927821c to your computer and use it in GitHub Desktop.
dolist-with-progress-reporter
(defmacro my-dolist-with-progress-reporter (spec message &rest body)
(declare (indent 2) (debug ((symbolp form &optional form) form body)))
(let ((list-var (make-symbol "list"))
(length-var (make-symbol "length"))
(counter-var (make-symbol "counter"))
(progress-var (make-symbol "progress")))
`(let* ((,list-var ,(nth 1 spec))
(,length-var (length ,list-var))
(,counter-var 0)
(,progress-var (make-progress-reporter ,message 0 ,length-var)))
(prog1
(dolist (,(car spec) ,list-var ,@(cddr spec))
,@body
(progress-reporter-update ,progress-var (incf ,counter-var)))
(progress-reporter-done ,progress-var)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment