unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Phil Hagelberg <phil@hagelb.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Chong Yidong <cyd@stupidchicken.com>,
	scymtym@gmx.net, emacs-devel@gnu.org
Subject: Re: CEDET merge
Date: Fri, 02 Oct 2009 10:46:19 -0700	[thread overview]
Message-ID: <877hvdu1sk.fsf@hagelb.org> (raw)
In-Reply-To: <jwvhbuj1tmp.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 01 Oct 2009 03:07:25 -0400")

[-- Attachment #1: Type: text/plain, Size: 691 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-pulsing-progress-reporter-functionality.patch --]
[-- Type: text/x-diff, Size: 3855 bytes --]

From 91f10af059ab03d50da990a332995b93aa4fcfbc Mon Sep 17 00:00:00 2001
From: Phil Hagelberg <technomancy@gmail.com>
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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Update-pulsing-reporters-to-work-with-regular-report.patch --]
[-- Type: text/x-diff, Size: 4320 bytes --]

From 89616487ab6f10fb5ec2d6369bddaf58745a40b3 Mon Sep 17 00:00:00 2001
From: Phil Hagelberg <technomancy@gmail.com>
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


  reply	other threads:[~2009-10-02 17:46 UTC|newest]

Thread overview: 194+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-28 15:31 CEDET merge Chong Yidong
2009-09-28 17:31 ` Ulrich Mueller
2009-09-28 17:55   ` Chong Yidong
2009-09-28 18:42     ` Ulrich Mueller
2009-09-28 19:30       ` Chong Yidong
2009-09-28 20:03         ` Ulrich Mueller
2009-09-28 20:20           ` Rupert Swarbrick
2009-09-28 22:16             ` Ulrich Mueller
2009-09-28 17:47 ` Eli Zaretskii
2009-09-28 18:00 ` Eli Zaretskii
2009-09-28 18:25   ` Chong Yidong
2009-09-28 19:23     ` Eli Zaretskii
2009-09-28 19:27       ` Andreas Schwab
2009-09-28 18:20 ` Phil Hagelberg
2009-09-28 22:10   ` Chong Yidong
2009-09-28 22:25     ` Phil Hagelberg
2009-09-30 16:38     ` Phil Hagelberg
2009-09-30 17:29       ` Chong Yidong
2009-09-30 21:43         ` Phil Hagelberg
2009-10-01  1:19           ` Chong Yidong
2009-10-01  3:20             ` Phil Hagelberg
2009-10-01  5:14               ` Phil Hagelberg
2009-10-01  7:07                 ` Stefan Monnier
2009-10-02 17:46                   ` Phil Hagelberg [this message]
2010-03-17 18:24                     ` progress-reporter (was: CEDET merge) Michael Albinus
2009-09-28 19:34 ` CEDET merge Andreas Schwab
2009-09-28 20:20   ` Andreas Schwab
2009-09-28 20:20 ` Alan Mackenzie
2009-09-28 21:57   ` Chong Yidong
2009-09-29  4:28 ` Glenn Morris
2009-09-29 11:28   ` Eric M. Ludlam
2009-09-30  9:32 ` Juanma Barranquero
2009-09-30 18:38   ` Eli Zaretskii
2009-09-30 19:32     ` Juanma Barranquero
2009-09-30 10:29 ` Sascha Wilde
2009-10-01 10:58   ` Sascha Wilde
2009-10-01 11:38     ` Eric M. Ludlam
2009-10-01 12:51       ` Sascha Wilde
2009-10-01 16:28         ` Sascha Wilde
2009-10-03 13:07           ` Eric M. Ludlam
2009-10-03 21:01             ` Sascha Wilde
2009-10-06 16:15               ` Sascha Wilde
2009-10-06 17:51                 ` Chong Yidong
2009-10-07  9:34                   ` Problems with EDE (was: CEDET merge) Sascha Wilde
2009-10-07  9:49                     ` Problems with EDE Sascha Wilde
2009-10-07 16:32                       ` Eric M. Ludlam
2009-10-08  1:51                         ` Chong Yidong
2009-10-08  2:17                           ` Chong Yidong
2009-10-08  9:53                             ` Sascha Wilde
2009-10-08 20:51                               ` Sascha Wilde
2009-10-08 12:04                             ` Eric M. Ludlam
2009-10-08 13:38                               ` Miles Bader
2009-10-08 13:46                               ` Sascha Wilde
2009-10-08 14:16                                 ` Chong Yidong
2009-10-08 19:46                                   ` Sascha Wilde
2009-10-08 14:11                               ` Chong Yidong
2009-10-08 14:16                                 ` David Kastrup
2009-10-14  1:56                                 ` Eric M. Ludlam
2009-10-08 18:32                               ` defalias customize-* in ede.el (was: Problems with EDE) Reiner Steib
2009-10-08 20:58                       ` Problems with EDE Sascha Wilde
2009-10-08 22:15                         ` Chong Yidong
2009-10-09  8:03                           ` Eli Zaretskii
2009-10-09 12:15                           ` Sascha Wilde
2009-10-15  3:45                             ` Eric M. Ludlam
2009-10-15  8:58                               ` Sascha Wilde
2009-10-15 14:38                                 ` Chong Yidong
2009-10-17 14:27                                   ` Chong Yidong
2009-10-20 13:22                                     ` Sascha Wilde
2009-10-14  2:34                           ` Eric M. Ludlam
2009-10-09 12:34                         ` Sascha Wilde
2009-10-09 12:42                           ` Sascha Wilde
2009-10-10  0:24                             ` Eric M. Ludlam
2009-10-10  7:34                               ` Sascha Wilde
2009-10-15  3:05                             ` Eric M. Ludlam
2009-10-09 17:10                           ` Andreas Schwab
2009-10-09 18:08                             ` Chong Yidong
2009-10-09 18:54                               ` Sascha Wilde
2009-10-09 19:14                                 ` Sascha Wilde
2009-10-09 20:33                                   ` Chong Yidong
2009-10-09 21:19                                     ` Sascha Wilde
2009-10-14  2:43                                       ` Eric M. Ludlam
2009-10-09 19:46                               ` Eric M. Ludlam
2009-10-08 22:21                     ` Chong Yidong
2009-10-03 20:10       ` CEDET merge Chong Yidong
2009-10-03 20:31         ` Eric M. Ludlam
2009-10-04  1:44           ` Chong Yidong
2009-10-04  2:30             ` Eric M. Ludlam
2009-10-04  5:52               ` Chong Yidong
2009-10-01  3:58 ` Miles Bader
2009-10-01 11:31   ` Eric M. Ludlam
2009-10-01 14:48     ` Chong Yidong
2009-10-07  3:43 ` Phil Hagelberg
2009-10-07  5:37   ` Chong Yidong
2009-10-07 16:20     ` Eric M. Ludlam
  -- strict thread matches above, loose matches on Subject: below --
2012-09-16  1:55 Feature freeze on October 1 Chong Yidong
2012-09-16 15:30 ` David Engster
2012-09-16 19:04   ` Stefan Monnier
2012-09-26 20:24     ` CEDET merge (was: Feature freeze on October 1) David Engster
2012-09-30 13:55       ` CEDET merge David Engster
2012-09-30 14:10         ` David Engster
2012-09-30 18:58         ` Glenn Morris
2012-09-30 19:17           ` Paul Eggert
2012-10-01  0:16             ` Glenn Morris
2012-10-01  3:44         ` Chong Yidong
2012-10-01 11:44           ` Eric M. Ludlam
2012-10-01 15:17           ` David Engster
2012-10-01 17:48             ` Chong Yidong
2012-10-01 17:56               ` Chong Yidong
2012-10-02 15:24               ` Chong Yidong
2012-10-04 19:32         ` David Engster
2012-10-06 11:19           ` Chong Yidong
2012-10-06 11:30             ` David Engster
2012-10-06 14:24               ` Chong Yidong
2012-10-06 14:54                 ` Stefan Monnier
2012-10-06 17:29                   ` David Engster
2012-10-06 18:10                     ` Stefan Monnier
2012-10-07 11:19                       ` David Engster
2012-10-06 23:31                     ` Glenn Morris
2012-10-07  1:15                       ` Glenn Morris
2012-10-07 11:03                         ` David Engster
2012-10-27 14:40                           ` David Engster
2012-10-28 18:50                             ` Glenn Morris
2012-11-17  3:23                               ` Glenn Morris
2012-11-18 15:42                                 ` David Engster
2012-11-20  2:45                                   ` Glenn Morris
2012-11-21 13:09                                   ` Chong Yidong
2012-10-07 20:50                 ` David Engster
2012-11-08 12:32         ` Alex Ott
2012-10-02  2:44 Dmitry Gutov
2012-10-02  5:05 ` Chong Yidong
2012-10-02  5:56   ` David Engster
2017-01-12 19:32 CEDET Merge Edward John Steere
2017-01-12 19:45 ` Eli Zaretskii
2017-01-12 20:27   ` Edward John Steere
2017-01-12 20:10 ` Bastian Beischer
2017-01-12 20:40   ` Edward John Steere
2017-01-16 18:45     ` Edward John Steere
2017-01-16 19:30       ` Eli Zaretskii
2017-01-16 19:55         ` Edward John Steere
2017-01-16 20:06           ` Eli Zaretskii
2017-01-16 20:12             ` Edward John Steere
2017-01-17 15:59               ` Eli Zaretskii
2017-01-17 16:10                 ` Edward John Steere
2017-01-17 16:36                   ` Stephen Leake
2017-01-17 20:36                     ` Edward John Steere
2017-01-17 21:22                       ` Stephen Leake
2017-01-17 21:23                       ` David Engster
2017-01-18 10:12                         ` Edward Steere
2017-01-18 22:05                           ` David Engster
2017-01-19 18:01                             ` Edward John Steere
2017-01-19 21:57                               ` David Engster
2017-01-19 22:29                                 ` Karl Fogel
2017-01-20 22:20                                   ` David Engster
2017-01-20 22:40                                     ` Stefan Monnier
2017-01-20 22:57                                       ` David Engster
2017-01-21  0:08                                         ` Stefan Monnier
2017-01-21 12:02                                     ` Eli Zaretskii
2017-01-21 18:29                                       ` Glenn Morris
2017-01-21 18:37                                         ` Eli Zaretskii
2017-01-21 18:52                                           ` Glenn Morris
2017-01-21 19:50                                             ` Eli Zaretskii
2017-01-21 22:57                                               ` Paul Eggert
2017-01-22 16:08                                                 ` Eli Zaretskii
2017-01-22 22:00                                             ` David Engster
2017-01-23  1:37                                               ` Paul Eggert
2017-01-22 21:31                                 ` David Engster
2017-01-24 19:02                                   ` Edward John Steere
2017-01-26 19:54                                     ` Edward John Steere
2017-01-26 21:06                                       ` David Engster
2017-01-27  4:38                                         ` Edward Steere
2017-01-27 20:20                                   ` Edward John Steere
2017-01-27 21:04                                     ` David Engster
2017-01-28  9:23                                       ` Edward John Steere
2017-01-29 21:34                                         ` David Engster
2017-01-31 16:51                                           ` Lars Ingebrigtsen
2017-01-31 18:48                                             ` Ted Zlatanov
2017-01-28 13:45                                       ` Edward John Steere
2017-01-17 21:10                     ` David Engster
2017-01-17 21:25                       ` Stephen Leake
2017-01-16 20:26           ` David Engster
2017-01-16 20:37             ` Edward John Steere
2017-01-16 21:13               ` David Engster
2017-01-17  5:21                 ` Edward Steere
2017-01-17 21:06                   ` David Engster
2017-01-17 21:19                     ` Dmitry Gutov
2017-01-17 21:32                       ` David Engster
2017-01-18  3:10                         ` Lee Hinman
2017-01-18  5:31                           ` Edward John Steere
2017-01-18 12:58                             ` Stephen Leake
2017-01-18 21:57                             ` David Engster
2017-01-19 17:51                               ` Edward John Steere
2017-01-19 20:25                                 ` Lee Hinman
2017-01-29 19:25                                   ` John Wiegley
2017-01-21 18:06                               ` Eric Ludlam
2017-09-23 11:38 ` Charles A. Roelli
2017-09-23 12:55   ` Edward John Steere
2017-09-24  8:24     ` Charles A. Roelli
2017-09-26 18:31 Edward John Steere

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877hvdu1sk.fsf@hagelb.org \
    --to=phil@hagelb.org \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=scymtym@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).