From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Phil Hagelberg Newsgroups: gmane.emacs.devel Subject: Re: CEDET merge Date: Fri, 02 Oct 2009 10:46:19 -0700 Message-ID: <877hvdu1sk.fsf@hagelb.org> References: <87hbun9jbs.fsf@stupidchicken.com> <87ocov9bji.fsf@hagelb.org> <8763b2pvo0.fsf@stupidchicken.com> <8763b0z8uo.fsf@hagelb.org> <87vdj08hp0.fsf@stupidchicken.com> <87iqf0xg4q.fsf@hagelb.org> <87ab0bzzam.fsf@stupidchicken.com> <873a63yf44.fsf@hagelb.org> <87my4bwv8z.fsf@hagelb.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1254505675 12531 80.91.229.12 (2 Oct 2009 17:47:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 2 Oct 2009 17:47:55 +0000 (UTC) Cc: Chong Yidong , scymtym@gmx.net, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 02 19:47:47 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MtmDC-0006ZZ-UK for ged-emacs-devel@m.gmane.org; Fri, 02 Oct 2009 19:46:36 +0200 Original-Received: from localhost ([127.0.0.1]:57439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtmDC-0004kn-Dy for ged-emacs-devel@m.gmane.org; Fri, 02 Oct 2009 13:46:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MtmD6-0004kI-A7 for emacs-devel@gnu.org; Fri, 02 Oct 2009 13:46:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MtmD2-0004jc-M1 for emacs-devel@gnu.org; Fri, 02 Oct 2009 13:46:28 -0400 Original-Received: from [199.232.76.173] (port=60183 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtmD2-0004jQ-F3 for emacs-devel@gnu.org; Fri, 02 Oct 2009 13:46:24 -0400 Original-Received: from caiajhbdcaib.dreamhost.com ([208.97.132.81]:60681 helo=homiemail-a12.g.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MtmD1-0001M5-Qa for emacs-devel@gnu.org; Fri, 02 Oct 2009 13:46:24 -0400 Original-Received: from enigma (96-26-232-193.sea.clearwire-dns.net [96.26.232.193]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by homiemail-a12.g.dreamhost.com (Postfix) with ESMTPSA id EBCFC714060; Fri, 2 Oct 2009 10:46:20 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Thu, 01 Oct 2009 03:07:25 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115858 Archived-At: --=-=-= Stefan Monnier 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-pulsing-progress-reporter-functionality.patch >From 91f10af059ab03d50da990a332995b93aa4fcfbc Mon Sep 17 00:00:00 2001 From: Phil Hagelberg 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-Update-pulsing-reporters-to-work-with-regular-report.patch >From 89616487ab6f10fb5ec2d6369bddaf58745a40b3 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg 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 --=-=-=--