Skip to content

Commit

Permalink
map-with-progress-reporter: evaluate MSG before calling MAP function
Browse files Browse the repository at this point in the history
This is useful when evaluating SEQUENCE takes a long time but
not long enough to justify a seperate progress-reporter.
  • Loading branch information
tarsius committed Aug 12, 2010
1 parent 460612a commit c78f5c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions map-progress.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

;; Author: Jonas Bernoulli <jonas@bernoul.li>
;; Created: 20100714
;; Updated: 20100714
;; Version: 0.1
;; Updated: 20100810
;; Version: 0.1+
;; Homepage: https://github.com/tarsius/map-progress/
;; Keywords: convenience

Expand Down Expand Up @@ -59,13 +59,15 @@
Report progress in the echo. Also see `make-progress-reporter'.
\(fn MESSAGE MAP FUNCTION SEQUENCE [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])"
(let ((idx (make-symbol "--progress-mapcan-idx--"))
(msm (make-symbol "--progress-mapcan-msm--"))
(lst (make-symbol "--progress-mapcan-lst--"))
(prg (make-symbol "--progress-mapcan-prg--"))
(elt (make-symbol "--progress-mapcan-elt--")))
`(let* ((,idx 0)
(,msm ,msg)
(,lst ,seq)
(,prg (make-progress-reporter
,msg (or ,min 0) (or ,max (length ,lst)) ,@rest)))
,msm (or ,min 0) (or ,max (length ,lst)) ,@rest)))
(prog1 (funcall ,map (lambda (,elt)
(prog1 (funcall ,fn ,elt)
(progress-reporter-update ,prg (incf ,idx))))
Expand Down

0 comments on commit c78f5c4

Please sign in to comment.