Improve progress-reporter state to remove hard coded length (bug#80988)

Remove hard-coded state range, now a monotonically increasing
integer.

* lisp/subr.el (progress-reporter-update-functions): Update
docstring.
(progress-reporter-echo-area): Use
'progress-reporter--pulse-characters' length.
(progress-reporter-do-update): Increase 'state' by 1 each pass.
*
lisp/system-taskbar.el (system-taskbar--progress-reporter-update):
Make steps independent of 'progress-reporter-echo-area' steps.
This commit is contained in:
Stéphane Marks 2026-05-27 16:05:23 -04:00 committed by Stefan Monnier
parent 30df8657fb
commit e4350c538f
2 changed files with 9 additions and 7 deletions

View file

@ -7114,8 +7114,7 @@ REPORTER is the result of a call to `make-progress-reporter'.
STATE can be one of:
- A float representing the percentage complete in the range 0.0-1.0
for a numeric reporter.
- An integer representing the index which cycles through the range 0-3
for a pulsing reporter.
- A monotonically increasing integer for a pulsing reporter.
- The symbol `done' to indicate that the progress reporter is complete.")
(defsubst progress-reporter-update (reporter &optional value suffix)
@ -7130,7 +7129,7 @@ MIN-VALUE and MAX-VALUE.
Optional argument SUFFIX is a string to be displayed after REPORTER's
main message and progress text. If REPORTER is a non-numerical
reporter, then VALUE should be nil, or a string to use instead of
SUFFIX. SUFFIX is considered obsolete and may be removed in the future.
SUFFIX.
See `progress-reporter-update-functions' for the list of functions
called on each update.
@ -7241,8 +7240,9 @@ area is busy with something else."
(message "%s" text)))
((pred integerp)
(let ((message-log-max nil)
(pulse-char (aref progress-reporter--pulse-characters
state)))
(pulse-char
(aref progress-reporter--pulse-characters
(mod state (length progress-reporter--pulse-characters)))))
(message "%s %s" text pulse-char)))
('done
(message "%sdone" text))))))
@ -7294,7 +7294,7 @@ area is busy with something else."
(if suffix
(aset parameters 6 suffix)
(setq suffix (or (aref parameters 6) "")))
(let ((index (mod (1+ (car reporter)) 4)))
(let ((index (1+ (car reporter))))
(setcar reporter index)
(run-hook-with-args 'progress-reporter-update-functions
reporter

View file

@ -282,7 +282,9 @@ REPORTER and STATE are the same as in
((pred floatp)
(system-taskbar--progress state))
((pred integerp)
(system-taskbar--progress (/ (1+ state) 4.0)))
;; This won't show 0.0 to indicate work in process until done.
(system-taskbar--progress
(/ (1+ (mod state 5)) 5.0)))
('done
(system-taskbar--progress nil)))))