From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Paul Pogonyshev Newsgroups: gmane.emacs.devel Subject: Re: simple patch for `etags.el' Date: Tue, 21 Sep 2004 00:08:09 -0200 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <200409210008.09116.pogonyshev@gmx.net> References: <200409201650.26315.pogonyshev@gmx.net> <200409202325.47369.pogonyshev@gmx.net> <200409210006.24183.pogonyshev@gmx.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1095714293 15635 80.91.229.6 (20 Sep 2004 21:04:53 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 20 Sep 2004 21:04:53 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 20 23:04:44 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1C9VL2-00028L-00 for ; Mon, 20 Sep 2004 23:04:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C9VQv-00087c-9u for ged-emacs-devel@m.gmane.org; Mon, 20 Sep 2004 17:10:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C9VQp-00086u-6H for emacs-devel@gnu.org; Mon, 20 Sep 2004 17:10:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C9VQn-00084M-J5 for emacs-devel@gnu.org; Mon, 20 Sep 2004 17:10:42 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C9VQn-00084C-FU for emacs-devel@gnu.org; Mon, 20 Sep 2004 17:10:41 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.34) id 1C9VKs-0003CQ-C8 for emacs-devel@gnu.org; Mon, 20 Sep 2004 17:04:34 -0400 Original-Received: (qmail 6728 invoked by uid 65534); 20 Sep 2004 21:04:31 -0000 Original-Received: from unknown (EHLO localhost.localdomain) (195.50.12.121) by mail.gmx.net (mp006) with SMTP; 20 Sep 2004 23:04:31 +0200 X-Authenticated: #16844820 Original-To: emacs-devel@gnu.org User-Agent: KMail/1.4.3 In-Reply-To: <200409210006.24183.pogonyshev@gmx.net> 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: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:27347 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:27347 > I wrote: > > I wrote: > > > This patch speeds building of tags table completion up several > > > times. > > > > Better yet, how about generalizing progress reporting > > between modules? For instance, it could look like this... > > Or even better, like this. Timing showed that it is cheaper > to not use `current-time'. Also simpler a lot. > > Paul > > > (defun make-progress-reporter (format-string > min-value max-value &optional current-va= lue) > "Return a list suitable for reporting operation progress with > `progress-reporter-update'. > > FORMAT-STRING must contain a single %-sequence, `%d', which will > be substituted with the progress percentage. If, for some > reason, you need to change this string, simply create a new > reporter. > > MIN-VALUE and MAX-VALUE designate starting (0% complete) and > final (100% complete) states of operation. Optional > CURRENT-VALUE specifies the progress by the moment you call this > function. You should omit it in most cases." > (let ((reporter (list min-value ;; Force a call to `message' now. > min-value > (/ (float (- max-value min-value)) 100.0) > format-string))) > (progress-reporter-update reporter (or current-value min-value)) > reporter)) > > (defsubst progress-reporter-update (reporter value) > "Report progress of an operation in the minibuffer. > > 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 inexpensive. It never prints same percentage > more than once, so it will not call `message' more than 101 times > in total during whole operation." > (when (>=3D value (car reporter)) > (progress-reporter-do-update reporter value))) > > (defun progress-reporter-do-update (reporter value) > (let* ((min-value (nth 1 reporter)) > =09 (one-percent (nth 2 reporter)) > =09 (percentage (truncate (/ (- value min-value) one-percent)))) > (message (nth 3 reporter) percentage) > (setcar reporter (+ min-value (* (1+ percentage) one-percent))) > (when (integerp value) > (setcar reporter (ceiling (car reporter)))))))