From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/76889 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: make-progress-reporter suggestions: 'modeline and customizable progress-reporter--pulse-characters Date: Thu, 17 Feb 2011 22:43:54 +0100 Message-ID: <87tyg272w5.fsf@gmx.de> References: <87ei76yi1x.fsf@lifelogs.com> <87lj1ergg5.fsf@gmx.de> <87ipwi3hjm.fsf@lifelogs.com> <87fwrmr6gf.fsf@gmx.de> <8739nm1u6n.fsf_-_@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1297979065 22660 80.91.229.12 (17 Feb 2011 21:44:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 17 Feb 2011 21:44:25 +0000 (UTC) Cc: ding@gnus.org, emacs-devel@gnu.org To: Ted Zlatanov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 17 22:44:17 2011 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.69) (envelope-from ) id 1PqBe5-0006bP-7p for ged-emacs-devel@m.gmane.org; Thu, 17 Feb 2011 22:44:17 +0100 Original-Received: from localhost ([127.0.0.1]:52101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PqBe4-0001C7-PY for ged-emacs-devel@m.gmane.org; Thu, 17 Feb 2011 16:44:16 -0500 Original-Received: from [140.186.70.92] (port=57057 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PqBdw-00018a-SY for emacs-devel@gnu.org; Thu, 17 Feb 2011 16:44:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PqBdt-0005nQ-5d for emacs-devel@gnu.org; Thu, 17 Feb 2011 16:44:08 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:35880) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PqBds-0005nG-Pl for emacs-devel@gnu.org; Thu, 17 Feb 2011 16:44:05 -0500 Original-Received: (qmail invoked by alias); 17 Feb 2011 21:44:01 -0000 Original-Received: from p57BB922D.dip0.t-ipconnect.de (EHLO detlef.gmx.de) [87.187.146.45] by mail.gmx.net (mp035) with SMTP; 17 Feb 2011 22:44:01 +0100 X-Authenticated: #3708877 X-Provags-ID: V01U2FsdGVkX19q9U5ktONqIZPhMVZQAR38617HaNyZq0q0Ngqyyo m2nIPdws+CICFr In-Reply-To: <8739nm1u6n.fsf_-_@lifelogs.com> (Ted Zlatanov's message of "Thu, 17 Feb 2011 10:50:56 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 213.165.64.23 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:136150 gmane.emacs.gnus.general:76889 Archived-At: --=-=-= Content-Type: text/plain Ted Zlatanov writes: > How about (showing both proposed use cases) > > (setq pr1 (make-progress-reporter 'modeline)) > (setq pr4 (make-progress-reporter 'modeline 0 100)) > (while t > (progress-reporter-update pr1) > (progress-reporter-update pr4)) > > to work in conjunction with a %/ in the modeline? The idea is that it > is guaranteed to be 1 or log10(max)+2 characters (non-numeric or > numeric) wide in this mode and it won't make any noise in the echo area. As proof of concept the appended patch. I don't use a special "%/" format in the modeline; instead of there is `mode-line-progress-reporter' which can be placed somewhere in `mode-line-format' (I've done it after `mode-line-remote'). You call (setq pr (make-progress-reporter)) (while t (progress-reporter-update pr)) No text in `make-progress-reporter' would be the modeline indicator; a text based progress reporter still writes in the minibuffer: (setq pr (make-progress-reporter "")) (while t (progress-reporter-update pr)) > Another suggestion for progress-reporter--pulse-characters for both > modeline and regular use: there are some Unicode glyphs which could be > used if the font supports them: > http://en.wikipedia.org/wiki/Harvey_Balls#Harvey_Balls_in_Unicode > > Maybe progress-reporter--pulse-characters could be customizable with > some presets like the above. That's for later. > Ted Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment === modified file 'lisp/bindings.el' --- lisp/bindings.el 2011-01-25 04:08:28 +0000 +++ lisp/bindings.el 2011-02-17 20:37:34 +0000 @@ -254,9 +254,13 @@ "Mode-line flag to show if default-directory for current buffer is remote.") ;;;###autoload (put 'mode-line-remote 'risky-local-variable t) - (make-variable-buffer-local 'mode-line-remote) +(defvar mode-line-progress-reporter nil + "Mode-line control for spinning progress-reporter.") +;;;###autoload +(put 'mode-line-progress-reporter 'risky-local-variable t) + ;; Actual initialization is below. (defvar mode-line-position nil "Mode-line control for displaying the position in the buffer. @@ -326,6 +330,7 @@ 'mode-line-client 'mode-line-modified 'mode-line-remote + 'mode-line-progress-reporter 'mode-line-frame-identification 'mode-line-buffer-identification (propertize " " 'help-echo help-echo) === modified file 'lisp/subr.el' --- lisp/subr.el 2011-02-01 21:37:12 +0000 +++ lisp/subr.el 2011-02-17 21:31:24 +0000 @@ -3486,7 +3486,7 @@ (>= value (car reporter))) ; For numerical reporter (progress-reporter-do-update reporter value))) -(defun make-progress-reporter (message &optional min-value max-value +(defun make-progress-reporter (&optional message min-value max-value current-value min-change min-time) "Return progress reporter object for use with `progress-reporter-update'. @@ -3553,6 +3553,7 @@ (min-value (aref parameters 1)) (max-value (aref parameters 2)) (text (aref parameters 3)) + (min-time (aref parameters 5)) (current-time (float-time)) (enough-time-passed ;; See if enough time has passed since the last update. @@ -3591,10 +3592,20 @@ (let ((index (mod (1+ (car reporter)) 4)) (message-log-max nil)) (setcar reporter index) - (message "%s %s" - text - (aref progress-reporter--pulse-characters - index))))))) + (if text + ;; Write into the minibuffer + (message "%s %s" + text + (aref progress-reporter--pulse-characters + index)) + ;; Update modeline + (let ((mode-line-progress-reporter + (list (propertize + (aref progress-reporter--pulse-characters index) + 'mouse-face 'mode-line-highlight))) + mode-line-remote) + (force-mode-line-update) + (sit-for min-time t)))))))) (defun progress-reporter-done (reporter) "Print reporter's message followed by word \"done\" in echo area." --=-=-=--