Tuesday, June 14, 2011

Emacs progress indication

When programming in emacs lisp, there is an easy way to show progress feedback to the user when a task will take some time. Here's a block of code from the elisp manual showing how to do it.

(let ((progress-reporter
(make-progress-reporter "Collecting mana for Emacs..."
0 500)))
(dotimes (k 500)
(sit-for 0.01)
(progress-reporter-update progress-reporter k))
(progress-reporter-done progress-reporter))

I've incorporated this into my duplicate files code, linked below...

http://code.google.com/p/justinhj-emacs-utils/source/browse/trunk/duplicates.el


2 comments:

Jürgen said...

BTW, there is a nice macro for most common use cases:


(dotimes-with-progress-reporter (k 500) "Collecting mana for Emacs..."
(sleep-for 0.01))

Justin said...

Yeah that's neater thanks