[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: |
Fri, 02 Oct 2009 10:46:19 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> 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.
>
> Yes, that would be even better, thank you,
I've attached the patches that implement this. Pulsing reporters can use
progress-reporter-update like normal ones and can have their messages
changed using progress-reporter-force-update.
thanks!
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
>From 89616487ab6f10fb5ec2d6369bddaf58745a40b3 Mon Sep 17 00:00:00 2001
From: Phil Hagelberg <address@hidden>
Date: Fri, 2 Oct 2009 10:44:07 -0700
Subject: [PATCH] Update pulsing reporters to work with regular reporter
functions.
Use progress-reporter-update for updating and
progress-reporter-force-update to update message. Remove
message-changing from progress-reporter-pulse.
---
lisp/subr.el | 51 ++++++++++++++++++++++++++++-----------------------
1 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index e26783f..bbf2051 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3399,21 +3399,25 @@ The properties used on SYMBOL are `composefunc',
`sendfunc',
;; digits of precision, it doesn't really matter here. On the other
;; hand, it greatly simplifies the code.
-(defsubst progress-reporter-update (reporter value)
+(defsubst progress-reporter-update (reporter &optional value)
"Report progress of an operation in the echo area.
+
+The first parameter, REPORTER, should be the result of a call to
+`make-progress-reporter'. For reporters for which the max value
+is known, the second argument determines the actual progress of
+operation; it must be between MIN-VALUE and MAX-VALUE as passed
+to `make-progress-reporter'.
+
However, if the change since last echo area update is too small
or not enough time has passed, then do nothing (see
`make-progress-reporter' for details).
-First parameter, REPORTER, should be the result of a call to
-`make-progress-reporter'. Second, VALUE, determines the actual
-progress of operation; it must be between MIN-VALUE and MAX-VALUE
-as passed to `make-progress-reporter'.
-
-This function is very inexpensive, you may not bother how often
-you call it."
- (when (>= value (car reporter))
- (progress-reporter-do-update reporter value)))
+In this case, this function is very inexpensive, you need not
+care how often you call it."
+ (if (progress-reporter-pulsing-p reporter)
+ (progress-reporter-pulse reporter)
+ (when (>= value (car reporter))
+ (progress-reporter-do-update reporter value))))
(defun make-progress-reporter (message &optional min-value max-value
current-value min-change min-time)
@@ -3440,8 +3444,7 @@ at all. If OS is not capable of measuring fractions of
seconds,
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."
+return a \"pulsing\" progress reporter."
(unless min-time
(setq min-time 0.2))
(let ((reporter
@@ -3468,7 +3471,9 @@ change the displayed message."
(aset parameters 3 new-message))
(when (aref parameters 0)
(aset parameters 0 (float-time)))
- (progress-reporter-do-update reporter value)))
+ (if (progress-reporter-pulsing-p reporter)
+ (progress-reporter-pulse reporter)
+ (progress-reporter-do-update reporter value))))
(defun progress-reporter-do-update (reporter value)
(let* ((parameters (cdr reporter))
@@ -3510,19 +3515,19 @@ change the displayed message."
(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."
+(defun progress-reporter-pulsing-p (reporter)
+ "Return t if REPORTER has an unknown max value."
+ (null (aref (cdr reporter) 2)))
+
+(defun progress-reporter-pulse (reporter)
+ "Advance pulsing indicator of REPORTER."
(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)
+ (index (+ (aref parameters 1) 1)))
+ (aset parameters 1 index)
(let ((message-log-max nil)) ; No logging
(message "%s %s"
- (aref progress-pulse-values new-index)
- message))))
+ (aref progress-pulse-values (mod index 4))
+ (aref parameters 3)))))
(defun progress-reporter-done (reporter)
"Print reporter's message followed by word \"done\" in echo area."
--
1.6.0.4
- Re: CEDET merge, Phil Hagelberg, 2009/10/01
- Re: CEDET merge, Stefan Monnier, 2009/10/01
- 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
- Problems with EDE (was: CEDET merge), Sascha Wilde, 2009/10/07
- Re: Problems with EDE, Sascha Wilde, 2009/10/07