summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2005-01-22 21:39:38 +0000
committerMiles Bader <miles@gnu.org>2005-01-22 21:39:38 +0000
commit18643d1d412928c57690271c8b7a65e50503441f (patch)
treea9303ce501314fc316c20ca29928b2fa168d0421 /lisp/subr.el
parentcfa4901a57cc9920eec0401d8b33abac7d3f8e5b (diff)
parentddff82cf89b20912729a1483da3f28608b44115a (diff)
downloademacs-18643d1d412928c57690271c8b7a65e50503441f.tar.gz
emacs-18643d1d412928c57690271c8b7a65e50503441f.tar.bz2
emacs-18643d1d412928c57690271c8b7a65e50503441f.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-4
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-41 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-46 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-47 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-4 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-5 Update from CVS: exi/gnus-faq.texi ([4.1]): Typo. * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-6 Update from CVS
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el31
1 files changed, 29 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 36931acf628..2a5154b533e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1,7 +1,7 @@
;;; subr.el --- basic lisp subroutines for Emacs
;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1999, 2000, 2001, 2002, 2003,
-;; 2004 Free Software Foundation, Inc.
+;; 2004, 2005 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: internal
@@ -2711,7 +2711,7 @@ you call it."
(defun make-progress-reporter (message min-value max-value
&optional current-value
min-change min-time)
- "Return progress reporter object usage with `progress-reporter-update'.
+ "Return progress reporter object to be used with `progress-reporter-update'.
MESSAGE is shown in the echo area. When at least 1% of operation
is complete, the exact percentage will be appended to the
@@ -2800,5 +2800,32 @@ change the displayed message."
"Print reporter's message followed by word \"done\" in echo area."
(message "%sdone" (aref (cdr reporter) 3)))
+(defmacro dotimes-with-progress-reporter (spec 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).
+
+At each iteration MESSAGE followed by progress percentage is
+printed in the echo area. After the loop is finished, MESSAGE
+followed by word \"done\" is printed. This macro is a
+convenience wrapper around `make-progress-reporter' and friends.
+
+\(fn (VAR COUNT [RESULT]) MESSAGE BODY...)"
+ (declare (indent 2) (debug ((symbolp form &optional form) form body)))
+ (let ((temp (make-symbol "--dotimes-temp--"))
+ (temp2 (make-symbol "--dotimes-temp2--"))
+ (start 0)
+ (end (nth 1 spec)))
+ `(let ((,temp ,end)
+ (,(car spec) ,start)
+ (,temp2 (make-progress-reporter ,message ,start ,end)))
+ (while (< ,(car spec) ,temp)
+ ,@body
+ (progress-reporter-update ,temp2
+ (setq ,(car spec) (1+ ,(car spec)))))
+ (progress-reporter-done ,temp2)
+ nil ,@(cdr (cdr spec)))))
+
;; arch-tag: f7e0e6e5-70aa-4897-ae72-7a3511ec40bc
;;; subr.el ends here