[Top][All Lists]
[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 22:14:52 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
Phil Hagelberg <address@hidden> writes:
> Chong Yidong <address@hidden> writes:
>> Phil Hagelberg <address@hidden> writes:
>>
>>> (defun make-pulsing-progress-reporter (&optional message)
>>
>> I think `make-progress-reporter' should do "pulsing" automatically if
>> min-value and max-value are null, instead of providing a new function.
>
> Good idea. I will implement that and send a patch.
The attached patch implements this. So make-progress-reporter will make
a pulsing reporter when min-value and max-value are not specified.
I made it so that you must use progress-reporter-pulse to update a
pulsing reporter, but I realized afterwards that it would be easy enough
to have progress-reporter-update check to see if the reporter is a
pulsing one or not and call the correct function underneath without the
caller having to think about it.
If you think this is a good idea I can make the change.
-Phil
>From 91f10af059ab03d50da990a332995b93aa4fcfbc Mon Sep 17 00:00:00 2001
From: Phil Hagelberg <address@hidden>
Date: Wed, 30 Sep 2009 22:02:57 -0700
Subject: [PATCH] Add pulsing progress reporter functionality.
---
lisp/subr.el | 41 ++++++++++++++++++++++++++++++-----------
1 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index a7d3fcd..e26783f 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3415,9 +3415,8 @@ you call it."
(when (>= value (car reporter))
(progress-reporter-do-update reporter value)))
-(defun make-progress-reporter (message min-value max-value
- &optional current-value
- min-change min-time)
+(defun make-progress-reporter (message &optional min-value max-value
+ current-value min-change min-time)
"Return progress reporter object to be used with `progress-reporter-update'.
MESSAGE is shown in the echo area. When at least 1% of operation
@@ -3426,20 +3425,23 @@ MESSAGE. When you call `progress-reporter-done', word
\"done\"
is printed after the MESSAGE. You can change MESSAGE of an
existing progress reporter with `progress-reporter-force-update'.
-MIN-VALUE and MAX-VALUE designate starting (0% complete) and
-final (100% complete) states of operation. The latter should be
-larger; if this is not the case, then simply negate all values.
-Optional CURRENT-VALUE specifies the progress by the moment you
-call this function. You should omit it or set it to nil in most
-cases since it defaults to MIN-VALUE.
+If provided, MIN-VALUE and MAX-VALUE designate starting (0%
+complete) and final (100% complete) states of operation. The
+latter should be larger; if this is not the case, then simply
+negate all values. Optional CURRENT-VALUE specifies the progress
+by the moment you call this function. You should omit it or set
+it to nil in most cases since it defaults to MIN-VALUE.
Optional MIN-CHANGE determines the minimal change in percents to
report (default is 1%.) Optional MIN-TIME specifies the minimal
time before echo area updates (default is 0.2 seconds.) If
`float-time' function is not present, then time is not tracked
at all. If OS is not capable of measuring fractions of seconds,
-then this parameter is effectively rounded up."
+then this parameter is effectively rounded up.
+If MIN-VALUE and MAX-VALUE are unknown, they may be omitted to
+return a \"pulsing\" progress reporter. This should be updated
+using the `progress-reporter-pulse' function instead."
(unless min-time
(setq min-time 0.2))
(let ((reporter
@@ -3447,7 +3449,7 @@ then this parameter is effectively rounded up."
(vector (if (and (fboundp 'float-time)
(>= min-time 0.02))
(float-time) nil)
- min-value
+ (or min-value 0)
max-value
message
(if min-change (max (min min-change 50) 1) 1)
@@ -3505,6 +3507,23 @@ change the displayed message."
(message "%s%d%%" (aref parameters 3) percentage)
(message "%s" (aref parameters 3))))))
+(defvar progress-pulse-values ["-" "\\" "|" "/"]
+ "Characters to use for pulsing progress reporters.")
+
+(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))))
+
(defun progress-reporter-done (reporter)
"Print reporter's message followed by word \"done\" in echo area."
(message "%sdone" (aref (cdr reporter) 3)))
--
1.6.0.4
- Re: CEDET merge,
Phil Hagelberg <=
- Re: CEDET merge, Sascha Wilde, 2009/10/01
- Re: CEDET merge, Eric M. Ludlam, 2009/10/01
- Re: CEDET merge, Sascha Wilde, 2009/10/01
- Re: CEDET merge, Sascha Wilde, 2009/10/01
- Re: CEDET merge, Eric M. Ludlam, 2009/10/03
- Re: CEDET merge, Sascha Wilde, 2009/10/03
- Re: CEDET merge, Sascha Wilde, 2009/10/06
- Re: CEDET merge, Chong Yidong, 2009/10/06