This question was originally asking for a custom progress indicator, but I've since removed the 'custom' requirement because I think the generalized case is more helpful to others.

I have added a command that takes a while to execute. Therefore I'd like to temporarily display a buffer with an animated textual progress indicator (rotating \|/-, perhaps) that updates with some frequency to show that the command is still running.

What's the best way to go about doing this?


Have a look at the Emacs progress reporter. See the Elisp manual (info "(elisp) Progress")

  • Thanks; this is almost exactly what I'm asking for! This is certainly the best way of displaying progress in Emacs. In this particular case I'm particularly looking for a way of accomplishing a custom indicator, however. Any ideas? – Caterpillar Nov 17 '17 at 13:22
  • 1
    Some years ago I've proposed a patch which would show the progress reporter in the modeline instead of the minibuffer. Also, the rotating characters could be customized. Somehow, it didn't find the way into Emacs. Look at <lists.gnu.org/archive/html/emacs-devel/2011-02/msg00764.html>, maybe you could make use of my patch. (And maybe I should reanimate it, and contribute as ELPA package). – Michael Albinus Nov 17 '17 at 13:39
  • Awesome, I'll have a look! Thanks! Once this question has been up for a while I'll consider accepting this answer since it'll answer the majority of those that come calling for a progress indicator. – Caterpillar Nov 17 '17 at 13:46

Just for fun.

(defun mode-line-progressbar-demo ()
  "Displays a progressbar in the mode-line."
  (let* ((mode-line-format mode-line-format)
         (max (window-width))
         (duration 3)
         (delta (max 0 (/ (float duration) max)))
         (message "Processing"))
        (dotimes (i max)
          (let* ((text (format "%s %.2f%%%%" message (* 100 (/ (float i) max))))
                 (fill (ceiling (/ (max 0 (- max (length text))) (float 2))))
                 (msg (concat (make-string fill ?\s) text (make-string fill ?\s))))
            (put-text-property 0 i 'face '(:background "royalblue") msg)
            (setq mode-line-format msg)
            (sit-for delta)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.