Function: with-tramp-progress-reporter

with-tramp-progress-reporter is a macro defined in tramp.el.gz.

Signature

(with-tramp-progress-reporter VEC LEVEL MESSAGE &rest BODY)

Documentation

Execute BODY, spinning a progress reporter with MESSAGE in interactive mode.

If LEVEL does not fit for visible messages, there are only traces without a visible progress reporter.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defmacro with-tramp-progress-reporter (vec level message &rest body)
  "Execute BODY, spinning a progress reporter with MESSAGE in interactive mode.
If LEVEL does not fit for visible messages, there are only traces
without a visible progress reporter."
  (declare (indent 3) (debug t))
  `(if (or noninteractive inhibit-message)
       (progn ,@body)
     (tramp-message ,vec ,level "%s..." ,message)
     (let* ((cookie "failed")
            ;; We create a pulsing progress reporter when there is no
            ;; other progress reporter running, and when there is a
            ;; minimum level.
            (pr (and (null tramp-inhibit-progress-reporter)
		     (<= ,level (min tramp-verbose 3))
		     (make-progress-reporter ,message)))
            ;; We start it after 3 seconds.
            (tm
	     (when pr
	       (run-at-time 3 0.1 #'tramp-progress-reporter-update pr))))
       (unwind-protect
           ;; Execute the body.
           (prog1
	       ;; Suppress concurrent progress reporter messages.
	       (let ((tramp-inhibit-progress-reporter
		      (or tramp-inhibit-progress-reporter tm)))
		 ,@body)
	     (setq cookie "done"))
         ;; Stop progress reporter.
	 (when (and tm pr)
	   (cancel-timer tm)
	   (let (message-log-max)
	     (progress-reporter-done pr)))
         (tramp-message ,vec ,level "%s...%s" ,message cookie)))))