From e4350c538f4a2a9f1199812bdb38c3d2b73f20e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Marks?= Date: Wed, 27 May 2026 16:05:23 -0400 Subject: [PATCH] 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. --- lisp/subr.el | 12 ++++++------ lisp/system-taskbar.el | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index d97598ab61f..16234d313a7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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 diff --git a/lisp/system-taskbar.el b/lisp/system-taskbar.el index cc41183fb32..973b426e026 100644 --- a/lisp/system-taskbar.el +++ b/lisp/system-taskbar.el @@ -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)))))