emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CEDET merge


From: Phil Hagelberg
Subject: Re: CEDET merge
Date: Wed, 30 Sep 2009 14:43:49 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

Chong Yidong <address@hidden> writes:

> Phil Hagelberg <address@hidden> writes:
>> The reason Rudel uses the CEDET one vs the built-in Emacs one is that it
>> needs a way to indicate that something is happening without knowing the
>> overall percentage of the task that is actually complete. I believe this
>> is commonly known as "pulsing" or a "spinner".
>>
>> We could probably implement this as an addition to the built-in progress
>> reporter in subr.el; would this be a welcome feature?
>
> Yes, and it should be easy to implement too.

Here's what I've come up with:

(defvar progress-pulse-values ["-" "\\" "|" "/"]
  "A vector of characters to use for pulsing progress reporters.")

(defun make-pulsing-progress-reporter (&optional message)
  "Return a pulsing progress reporter that display MESSAGE.
MESSAGE can contain all formatting characters accepted by
`format'. If message is nil, the string \"Working ...\" is
displayed.

Example:
(let ((rep (make-pulsing-progress-reporter \"Connecting\")))
  (dotimes (n 3)
    (sleep-for 0.1)
    (progress-reporter-pulse rep \"Connecting [new]\"))
  (dotimes (n 3)
    (sleep-for 0.1)
    (progress-reporter-pulse rep \"Connecting [synching]\"))
  (dotimes (n 3)
    (sleep-for 0.1)
    (progress-reporter-pulse rep \"Connecting [idle]\"))
  (progress-reporter-pulse rep \"Connecting \")
  (progress-reporter-done rep))"
  (cons nil ; total value is not known
    (vector nil 0 'dummy (or message "Working ... "))))

(defun progress-reporter-pulse (reporter &optional new-message)
  "Advance pulsing indicator of REPORTER. Display NEW-MESSAGE if given."
  (let* ((parameters (cdr reporter))
         (message    (or new-message (aref parameters 3)))
         (index      (aref parameters 1))
         (new-index  (mod (+ index 1) 4)))
    (aset parameters 1 new-index)
    (aset parameters 3 message)
    (let ((message-log-max nil)) ; No logging
      (message "%s %s"
               (aref progress-pulse-values new-index)
               message))))

The example in the docstring should make it clear how this works. It's
fairly close to how the existing progress reporter works, but it's got
nil in a couple places in the data structure due to not knowing the
total progress.

I have my paperwork in. I could submit this as a patch if that's more
convenient, or you could find a place for it in subr.el.

Thanks!

-Phil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]