Created
January 8, 2015 15:25
-
-
Save legoscia/931322eaa70c8927821c to your computer and use it in GitHub Desktop.
dolist-with-progress-reporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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