Function: progress-reporter-do-update

progress-reporter-do-update is a byte-compiled function defined in subr.el.gz.

Signature

(progress-reporter-do-update REPORTER VALUE &optional SUFFIX)

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun progress-reporter-do-update (reporter value &optional suffix)
  (let* ((parameters      (cdr reporter))
	 (update-time     (aref parameters 0))
	 (min-value       (aref parameters 1))
	 (max-value       (aref parameters 2))
	 (enough-time-passed
	  ;; See if enough time has passed since the last update.
	  (or (not update-time)
	      (when (time-less-p update-time nil)
		;; Calculate time for the next update
		(aset parameters 0 (+ update-time (aref parameters 5)))))))
    (cond ((and min-value max-value)
	   ;; Numerical indicator
	   (let* ((one-percent (/ (- max-value min-value) 100.0))
		  (percentage  (if (= max-value min-value)
				   0
				 (truncate (/ (- value min-value)
					      one-percent)))))
	     ;; Calculate NEXT-UPDATE-VALUE.  If we are not printing
	     ;; message because not enough time has passed, use 1
	     ;; instead of MIN-CHANGE.  This makes delays between echo
	     ;; area updates closer to MIN-TIME.
	     (setcar reporter
		     (min (+ min-value (* (+ percentage
					     (if enough-time-passed
						 ;; MIN-CHANGE
						 (aref parameters 4)
					       1))
					  one-percent))
			  max-value))
	     (when (integerp value)
	       (setcar reporter (ceiling (car reporter))))
	     ;; Print message only if enough time has passed
	     (when enough-time-passed
               (if suffix
                   (aset parameters 6 suffix)
                 (setq suffix (or (aref parameters 6) "")))
               (run-hook-with-args 'progress-reporter-update-functions
                                   reporter
                                   (/ percentage 100.0)))))
	  ;; Pulsing indicator
	  (enough-time-passed
           (when (and value (not suffix))
             (setq suffix value))
           (if suffix
               (aset parameters 6 suffix)
             (setq suffix (or (aref parameters 6) "")))
           (let ((index (mod (1+ (car reporter)) 4)))
	     (setcar reporter index)
             (run-hook-with-args 'progress-reporter-update-functions
                                 reporter
                                 index))))))