+2006-11-07 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+
+ * elmo-util.el (elmo-progress-start): Accept nil for `total'. Set
+ `elmo-progress-counter' as t when a query callback returns nil.
+ (elmo-progress-clear): New function.
+ (elmo-progress-done): Split into `elmo-progress-clear'.
+ (elmo-progress-notify): Update a total slot when it is nil.
+ (elmo-with-progress-display): Call `elmo-progress-clear' in
+ unwind-protect and move calling `elmo-progress-done' to outside.
+
+ * elmo-imap4.el (elmo-imap4-find-next-line): Call
+ `elmo-progress-notify' with :total parameter instead of
+ `elmo-progress-counter-set-total'.
+
2006-11-07 Tetsurou Okazaki <okazaki@be.to>
* elmo-util.el (elmo-cache-expire-by-age): Add docstring.
(if (match-string 1)
(if (< (point-max) (+ (point) (string-to-number (match-string 1))))
(progn
- (when (elmo-progress-counter-label
- elmo-imap4-literal-progress-reporter)
- (elmo-progress-counter-set-total
- elmo-imap4-literal-progress-reporter
- (string-to-number (match-string 1)))
- (elmo-progress-notify 'elmo-retrieve-message
- :set (- (point-max) (point))))
+ (when elmo-imap4-literal-progress-reporter
+ (elmo-progress-notify
+ 'elmo-retrieve-message
+ :set (- (point-max) (point))
+ :total (string-to-number (match-string 1))))
nil)
(goto-char (+ (point) (string-to-number (match-string 1))))
(elmo-imap4-find-next-line))
(setq elmo-imap4-fetch-callback nil)
(setq elmo-imap4-fetch-callback-data nil))
(elmo-with-progress-display (elmo-retrieve-message
- (or (elmo-message-field folder number :size)
- 0)
+ (elmo-message-field folder number :size)
elmo-imap4-literal-progress-reporter)
"Retrieving"
(setq response
(elmo-progress-counter-total counter))))
(defun elmo-progress-start (label total action)
- (when (and (> total 0)
- (null elmo-progress-counter))
+ (when (and (null elmo-progress-counter)
+ (or (null total)
+ (> total 0)))
(let ((counter (cons label (vector 0 total action))))
(elmo-progress-call-callback counter 'start)
- (when (elmo-progress-call-callback counter 'query)
- (elmo-progress-call-callback counter)
- (setq elmo-progress-counter counter))
+ (setq elmo-progress-counter
+ (cond ((null total)
+ counter)
+ ((elmo-progress-call-callback counter 'query)
+ (elmo-progress-call-callback counter)
+ counter)
+ (t
+ t)))
counter)))
-(defun elmo-progress-done (counter)
+(defun elmo-progress-clear (counter)
(when counter
- (when (elmo-progress-counter-label counter)
- (when (< (elmo-progress-counter-value counter)
- (elmo-progress-counter-total counter))
- (elmo-progress-call-callback counter 100))
- (elmo-progress-call-callback counter 'done))
- (when (eq counter elmo-progress-counter)
- (setq elmo-progress-counter nil))))
+ (when (and (elmo-progress-counter-label elmo-progress-counter)
+ (elmo-progress-counter-total elmo-progress-counter))
+ (elmo-progress-call-callback elmo-progress-counter 100))
+ (setq elmo-progress-counter nil)))
+
+(defun elmo-progress-done (counter)
+ (when (elmo-progress-counter-label counter)
+ (elmo-progress-call-callback counter 'done)))
(defun elmo-progress-notify (label &rest params)
- (when (and elmo-progress-counter
- (eq (elmo-progress-counter-label elmo-progress-counter) label))
+ (when (eq label (elmo-progress-counter-label elmo-progress-counter))
(let ((counter elmo-progress-counter))
- (elmo-progress-counter-set-value
- counter
- (or (plist-get params :set)
- (+ (elmo-progress-counter-value counter)
- (or (plist-get params :inc)
- (car params)
- 1))))
- (elmo-progress-call-callback counter))))
+ (if (or (elmo-progress-counter-total counter)
+ (and (elmo-progress-counter-set-total
+ counter
+ (plist-get params :total))
+ (elmo-progress-call-callback counter 'query)))
+ (progn
+ (elmo-progress-counter-set-value
+ counter
+ (or (plist-get params :set)
+ (+ (elmo-progress-counter-value counter)
+ (or (plist-get params :inc)
+ (car params)
+ 1))))
+ (elmo-progress-call-callback counter))
+ (setq elmo-progress-counter t)))))
(defmacro elmo-with-progress-display (spec message &rest body)
- "Evaluate BODY with progress gauge if CONDITION is non-nil.
+ "Evaluate BODY with progress message.
SPEC is a list as followed (LABEL TOTAL [VAR])."
(let ((label (nth 0 spec))
(total (nth 1 spec))
(unwind-protect
(progn
,@body)
- (elmo-progress-done ,var)))))
+ (elmo-progress-clear ,var))
+ (elmo-progress-done ,var))))
(put 'elmo-with-progress-display 'lisp-indent-function '2)
(def-edebug-spec elmo-with-progress-display