unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23088: 25.1.50; progress-reporter with 2 text messages
@ 2016-03-22 10:59 Tino Calancha
  2017-03-26  1:10 ` npostavs
  0 siblings, 1 reply; 3+ messages in thread
From: Tino Calancha @ 2016-03-22 10:59 UTC (permalink / raw)
  To: 23088

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


Adding a second optional message in progress-reporter
provides more control in the output format.
When both, NEW-MESSAGE and NEW-MESAGE2
are provided to `progress-reporter-force-update', the
structure of the output string would be as follows:

1) MESSAGE: it may be the operation under course.
2) As before, the status index (i.e., 30%).
3) MESSAGE2: it may be, i.e., the current file being processed.

In following example, the status index changes the position with
every message, which is distracting.

emacs -Q:
(let* ((games '("Mega Man"
 			   "Street Fighter II: The World Warrior"
 			   "Double Dragon"
 			   "Very long game with lot of stages: requires many months to complete"
 			   "The Legend Of Zelda"
 			   "Pac-Man"))
 	   (num-games (length games))
 	   (text "Checking game...")
 	   (prep (make-progress-reporter text 0 num-games)))
   (dotimes (i num-games)
 	(progress-reporter-force-update prep i
 					(format "Checking game... (%s) " (nth i games)))

 	(sit-for (or (and (= i 3) 5) 1)))
   (message "Games check completed!"))

; A second optional string allows to present the information as described in 1-2-3 above:
(progress-reporter-force-update prep i text
 				(format "(%s)" (nth i games)))

; This would display the index string in the same position for each update.



In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.29)
  of 2016-03-10 built on calancha-pc
Repository revision: 780a605e1d2de4b975e6f1f29b491c9af419dcff

[-- Attachment #2: Type: text/plain, Size: 3355 bytes --]

diff --git a/lisp/subr.el b/lisp/subr.el
index cad6319..e5325f4 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4711,7 +4711,7 @@ progress-reporter-update
     (progress-reporter-do-update reporter value)))
 
 (defun make-progress-reporter (message &optional min-value max-value
-				       current-value min-change min-time)
+				       current-value min-change min-time message2)
   "Return progress reporter object for use with `progress-reporter-update'.
 
 MESSAGE is shown in the echo area, with a status indicator
@@ -4739,7 +4739,9 @@ make-progress-reporter
 echo area updates (default is 0.2 seconds.)  If the function
 `float-time' is not present, time is not tracked at all.  If the
 OS is not capable of measuring fractions of seconds, this
-parameter is effectively rounded up."
+parameter is effectively rounded up.
+Optional MESSAGE2 is a text to follow the status indicator: i.e.
+the current file being processed."
   (when (string-match "[[:alnum:]]\\'" message)
     (setq message (concat message "...")))
   (unless min-time
@@ -4754,18 +4756,22 @@ make-progress-reporter
 		       max-value
 		       message
 		       (if min-change (max (min min-change 50) 1) 1)
-		       min-time))))
+		       min-time
+                       message2))))
     (progress-reporter-update reporter (or current-value min-value))
     reporter))
 
-(defun progress-reporter-force-update (reporter &optional value new-message)
+(defun progress-reporter-force-update (reporter &optional value new-message new-message2)
   "Report progress of an operation in the echo area unconditionally.
 
 The first two arguments are the same as in `progress-reporter-update'.
-NEW-MESSAGE, if non-nil, sets a new message for the reporter."
+NEW-MESSAGE, if non-nil, sets a new message for the reporter.
+NEW-MESSAGE2, if non-nil, sets a new message after the status indicator."
   (let ((parameters (cdr reporter)))
     (when new-message
       (aset parameters 3 new-message))
+    (when new-message2
+      (aset parameters 6 new-message2))
     (when (aref parameters 0)
       (aset parameters 0 (float-time)))
     (progress-reporter-do-update reporter value)))
@@ -4779,6 +4785,7 @@ progress-reporter-do-update
 	 (min-value    (aref parameters 1))
 	 (max-value    (aref parameters 2))
 	 (text         (aref parameters 3))
+	 (text2        (aref parameters 6))
 	 (enough-time-passed
 	  ;; See if enough time has passed since the last update.
 	  (or (not update-time)
@@ -4809,17 +4816,18 @@ progress-reporter-do-update
 	     ;; Only print message if enough time has passed
 	     (when enough-time-passed
 	       (if (> percentage 0)
-		   (message "%s%d%%" text percentage)
-		 (message "%s" text)))))
+		   (message "%s%d%% %s" text percentage (or text2 ""))
+		 (message "%s %s" text (or text2 ""))))))
 	  ;; Pulsing indicator
 	  (enough-time-passed
 	   (let ((index (mod (1+ (car reporter)) 4))
 		 (message-log-max nil))
 	     (setcar reporter index)
-	     (message "%s %s"
+	     (message "%s %s %s"
 		      text
 		      (aref progress-reporter--pulse-characters
-			    index)))))))
+			    index)
+                      (or text2 "")))))))
 
 (defun progress-reporter-done (reporter)
   "Print reporter's message followed by word \"done\" in echo area."

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#23088: 25.1.50; progress-reporter with 2 text messages
  2016-03-22 10:59 bug#23088: 25.1.50; progress-reporter with 2 text messages Tino Calancha
@ 2017-03-26  1:10 ` npostavs
  2019-06-04  1:15   ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: npostavs @ 2017-03-26  1:10 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 23088

Tino Calancha <f92capac@gmail.com> writes:

> Adding a second optional message in progress-reporter
> provides more control in the output format.
> When both, NEW-MESSAGE and NEW-MESAGE2
> are provided to `progress-reporter-force-update',

To make this useful, we should be able to pass NEW-MESSAGE2 to
`progress-reporter-update', so that the progress reporting machinery can
decide not to update the display if messages are coming in too fast.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#23088: 25.1.50; progress-reporter with 2 text messages
  2017-03-26  1:10 ` npostavs
@ 2019-06-04  1:15   ` Noam Postavsky
  0 siblings, 0 replies; 3+ messages in thread
From: Noam Postavsky @ 2019-06-04  1:15 UTC (permalink / raw)
  To: npostavs; +Cc: Tino Calancha, 23088

close 23088 
quit

npostavs@users.sourceforge.net writes:

> Tino Calancha <f92capac@gmail.com> writes:
>
>> Adding a second optional message in progress-reporter
>> provides more control in the output format.
>> When both, NEW-MESSAGE and NEW-MESAGE2
>> are provided to `progress-reporter-force-update',
>
> To make this useful, we should be able to pass NEW-MESSAGE2 to
> `progress-reporter-update', so that the progress reporting machinery can
> decide not to update the display if messages are coming in too fast.

I've implemented this now for Bug#35909, so I'm closing this bug.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-04  1:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-22 10:59 bug#23088: 25.1.50; progress-reporter with 2 text messages Tino Calancha
2017-03-26  1:10 ` npostavs
2019-06-04  1:15   ` Noam Postavsky

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).