branch: master commit bf5ed71dab670492a1eda3c474d748302f761127 Author: Michael Albinus <michael.albi...@gmx.de> Commit: Michael Albinus <michael.albi...@gmx.de>
Add progress reporter to debbugs * packages/debbugs/debbugs-ug.texi (Retrieving Bugs, Searching Bugs): Add debbugs-show-progress. * packages/debbugs/debbugs.el (debbugs-show-progress): New defcustom. (debbugs-progress-reporter, debbugs-progress-reporter-buffers): New defvars. (debbugs-url-display-percentage): New defun. (debbugs-get-bugs, debbugs-get-status, debbugs-search-est): Add progress reporter. * packages/debbugs/debbugs.texi (Configuration): Say user option instead of variable. Add debbugs-show-progress. --- packages/debbugs/debbugs-ug.info | 113 +++++++++++++++++++----------------- packages/debbugs/debbugs-ug.texi | 25 ++++---- packages/debbugs/debbugs.el | 120 ++++++++++++++++++++++++++++++++++----- packages/debbugs/debbugs.info | 39 +++++++------ packages/debbugs/debbugs.texi | 36 +++++++----- 5 files changed, 225 insertions(+), 108 deletions(-) diff --git a/packages/debbugs/debbugs-ug.info b/packages/debbugs/debbugs-ug.info index ee5fdb3..4ac061c 100644 --- a/packages/debbugs/debbugs-ug.info +++ b/packages/debbugs/debbugs-ug.info @@ -155,6 +155,11 @@ prefix. *note Presenting Bugs:: for the presentation of the results. + -- User Option: debbugs-show-progress + + If this user option is non-'nil', there is a progress report when + retrieving bugs. + File: debbugs-ug.info, Node: Searching Bugs, Next: Presenting Bugs, Prev: Retrieving Bugs, Up: Top @@ -277,6 +282,9 @@ changes of the same day. badly, because they could be applied only after all bugs have been downloaded. + These commands show also a progress report when + 'debbugs-show-progress' is non-'nil'. + ---------- Footnotes ---------- (1) This has been added to the Debbugs/SOAP backend of the GNU @@ -382,7 +390,6 @@ This enables the following key strokes: 'E' 'debbugs-gnu-make-control-message' Make (but don't yet send) a control message for this bug, *note Control Messages::. - The user option 'debbugs-gnu-suppress-closed' controls, whether closed bugs are shown in the initial list. @@ -423,7 +430,6 @@ This enables the following key strokes: 'C-c # E' 'debbugs-gnu-make-control-message' Make (but don't yet send) a control message for this bug, *note Control Messages::. - When the bug attributes are shown by 'org-cycle', there is a link 'Messages' which opens the messages for that bug. The user options @@ -564,7 +570,7 @@ meaning of the control messages, *Note Mail Command Index::. "usertag 12345 documentation" How the control messages are sent is controlled by the -'debbugs-gnu-send-mail-function' variable. If it is 'nil' (the +'debbugs-gnu-send-mail-function' user option. If it is 'nil' (the default value), the value of 'send-mail-function' is used. This could be inconvenient, for example when an external interactive mail client is configured. @@ -732,12 +738,13 @@ Variable Index * debbugs-gnu-default-suppress-bugs: Retrieving Bugs. (line 44) * debbugs-gnu-git-remote-info-alist: Customizing debbugs-gnu-pick-commits. (line 6) -* debbugs-gnu-mail-backend: Tabulated Lists. (line 83) +* debbugs-gnu-mail-backend: Tabulated Lists. (line 82) * debbugs-gnu-read-commit-range-hook: Posting Patches. (line 11) * debbugs-gnu-send-mail-function: Control Messages. (line 133) -* debbugs-gnu-suppress-closed: Tabulated Lists. (line 80) +* debbugs-gnu-suppress-closed: Tabulated Lists. (line 79) * debbugs-gnu-trunk-directory: Applying Patches. (line 18) * debbugs-org-severity-priority: TODO Items. (line 10) +* debbugs-show-progress: Retrieving Bugs. (line 96) File: debbugs-ug.info, Node: Key Index, Next: Mail Command Index, Prev: Variable Index, Up: Top @@ -764,7 +771,7 @@ Key Index * <mouse-2>: Tabulated Lists. (line 31) * R: Tabulated Lists. (line 42) * <RET>: Tabulated Lists. (line 29) -* <RET> <1>: Tabulated Lists. (line 83) +* <RET> <1>: Tabulated Lists. (line 82) * s: Tabulated Lists. (line 62) * t: Tabulated Lists. (line 65) * <TAB>: TODO Items. (line 16) @@ -1119,52 +1126,52 @@ Debbugs control mailserver commands Tag Table: Node: Top1097 Node: Retrieving Bugs2704 -Node: Searching Bugs6937 -Ref: Searching Bugs-Footnote-111250 -Ref: Searching Bugs-Footnote-211338 -Node: Presenting Bugs11429 -Node: Tabulated Lists12091 -Node: TODO Items15946 -Node: Control Messages17280 -Node: Applying Patches20794 -Node: Posting Patches22184 -Node: Customizing debbugs-gnu-pick-commits24669 -Node: Minor Mode25369 -Node: Command Index26645 -Node: Variable Index27505 -Node: Key Index28950 -Node: Mail Command Index30658 -Ref: Mail Command Index: reassign30811 -Ref: Mail Command Index: reopen31577 -Ref: Mail Command Index: found32731 -Ref: Mail Command Index: notfound33812 -Ref: Mail Command Index: fixed34221 -Ref: Mail Command Index: notfixed34667 -Ref: Mail Command Index: submitter35290 -Ref: Mail Command Index: forwarded35684 -Ref: Mail Command Index: notforwarded36301 -Ref: Mail Command Index: retitle36502 -Ref: Mail Command Index: severity36886 -Ref: Mail Command Index: clone37217 -Ref: Mail Command Index: merge37981 -Ref: Mail Command Index: forcemerge39368 -Ref: Mail Command Index: unmerge39812 -Ref: Mail Command Index: tags40515 -Ref: Mail Command Index: block41581 -Ref: Mail Command Index: unblock41618 -Ref: Mail Command Index: close42103 -Ref: Mail Command Index: package42753 -Ref: Mail Command Index: owner43365 -Ref: Mail Command Index: noowner43728 -Ref: Mail Command Index: archive43901 -Ref: Mail Command Index: unarchive44042 -Ref: Mail Command Index: #44335 -Ref: Mail Command Index: quit44595 -Ref: Mail Command Index: stop44602 -Ref: Mail Command Index: thank44609 -Ref: Mail Command Index: thanks44617 -Ref: Mail Command Index: thankyou44626 -Ref: Mail Command Index: thank you44637 -Ref: Mail Command Index: --44649 +Node: Searching Bugs7071 +Ref: Searching Bugs-Footnote-111481 +Ref: Searching Bugs-Footnote-211569 +Node: Presenting Bugs11660 +Node: Tabulated Lists12322 +Node: TODO Items16161 +Node: Control Messages17482 +Node: Applying Patches20999 +Node: Posting Patches22389 +Node: Customizing debbugs-gnu-pick-commits24874 +Node: Minor Mode25574 +Node: Command Index26850 +Node: Variable Index27710 +Node: Key Index29226 +Node: Mail Command Index30934 +Ref: Mail Command Index: reassign31087 +Ref: Mail Command Index: reopen31853 +Ref: Mail Command Index: found33007 +Ref: Mail Command Index: notfound34088 +Ref: Mail Command Index: fixed34497 +Ref: Mail Command Index: notfixed34943 +Ref: Mail Command Index: submitter35566 +Ref: Mail Command Index: forwarded35960 +Ref: Mail Command Index: notforwarded36577 +Ref: Mail Command Index: retitle36778 +Ref: Mail Command Index: severity37162 +Ref: Mail Command Index: clone37493 +Ref: Mail Command Index: merge38257 +Ref: Mail Command Index: forcemerge39644 +Ref: Mail Command Index: unmerge40088 +Ref: Mail Command Index: tags40791 +Ref: Mail Command Index: block41857 +Ref: Mail Command Index: unblock41894 +Ref: Mail Command Index: close42379 +Ref: Mail Command Index: package43029 +Ref: Mail Command Index: owner43641 +Ref: Mail Command Index: noowner44004 +Ref: Mail Command Index: archive44177 +Ref: Mail Command Index: unarchive44318 +Ref: Mail Command Index: #44611 +Ref: Mail Command Index: quit44871 +Ref: Mail Command Index: stop44878 +Ref: Mail Command Index: thank44885 +Ref: Mail Command Index: thanks44893 +Ref: Mail Command Index: thankyou44902 +Ref: Mail Command Index: thank you44913 +Ref: Mail Command Index: --44925 End Tag Table diff --git a/packages/debbugs/debbugs-ug.texi b/packages/debbugs/debbugs-ug.texi index f17df8d..0d83c3a 100644 --- a/packages/debbugs/debbugs-ug.texi +++ b/packages/debbugs/debbugs-ug.texi @@ -141,7 +141,6 @@ options @code{debbugs-gnu-default-severities} and @code{debbugs-gnu-default-packages}. @ref{Presenting Bugs} for the presentation of the results. - @end deffn @@ -162,7 +161,6 @@ A default value for interactive use could be configured in the user option @code{debbugs-gnu-default-bug-number-list}. @ref{Presenting Bugs} for the presentation of the results. - @end deffn @@ -175,9 +173,14 @@ show all unarchived bugs of the packages declared in This is useful for bug triages. @ref{Presenting Bugs} for the presentation of the results. - @end deffn +@defopt debbugs-show-progress + +If this user option is non-@code{nil}, there is a progress report when +retrieving bugs. +@end defopt + @node Searching Bugs @chapter Searching in the Debbugs Database @@ -298,6 +301,9 @@ are discriminated on the client side, which is indicated by the string "(client-side filter)" in the minibuffer after the attribute name. Note, that client side filters perform badly, because they could be applied only after all bugs have been downloaded. + +These commands show also a progress report when +@code{debbugs-show-progress} is non-@code{nil}. @end deffn @@ -434,7 +440,6 @@ Send a control message for this bug, @ref{Control Messages}. @code{debbugs-gnu-make-control-message} @* Make (but don't yet send) a control message for this bug, @ref{Control Messages}. - @end multitable @vindex debbugs-gnu-suppress-closed @@ -497,7 +502,6 @@ Send a control message for this bug, @ref{Control Messages}. @code{debbugs-gnu-make-control-message} @* Make (but don't yet send) a control message for this bug, @ref{Control Messages}. - @end multitable When the bug attributes are shown by @code{org-cycle}, there is a link @@ -637,15 +641,14 @@ address. The tag to be set is also read interactively. @item documentation "user emacs" @* "usertag 12345 documentation" - @end table @vindex debbugs-gnu-send-mail-function How the control messages are sent is controlled by the -@code{debbugs-gnu-send-mail-function} variable. If it is @code{nil} -(the default value), the value of @code{send-mail-function} is used. -This could be inconvenient, for example when an external interactive -mail client is configured. +@code{debbugs-gnu-send-mail-function} user option. If it is +@code{nil} (the default value), the value of @code{send-mail-function} +is used. This could be inconvenient, for example when an external +interactive mail client is configured. @node Applying Patches @@ -679,6 +682,7 @@ creates a ChangeLog entry with all needed information. A final @kbd{M-m} in the @samp{ChangeLog} buffer commits the patch via @samp{*vc-log*}. + @node Posting Patches @section Posting Patches to Debbugs from the Emacs Repository @@ -724,6 +728,7 @@ relevant bug thread message. This will insert some text describing the commit and where it was pushed to, and answering @kbd{y} will arrange for the bug to be closed when the message is sent. + @node Customizing debbugs-gnu-pick-commits @subsection Customizing debbugs-gnu-pick-commits diff --git a/packages/debbugs/debbugs.el b/packages/debbugs/debbugs.el index bf4c95e..071423e 100644 --- a/packages/debbugs/debbugs.el +++ b/packages/debbugs/debbugs.el @@ -123,6 +123,47 @@ t or 0 disables caching, nil disables expiring." (append debbugs-soap-invoke-async-object (car response)))) nil debbugs-wsdl debbugs-port operation-name parameters)) +(defcustom debbugs-show-progress t + "Whether progress report is shown." + :type 'boolean) + +(defvar debbugs-progress-reporter nil + "The progress reporter. +Don't set this globally, it shall be let-bound.") + +(defvar debbugs-progress-reporter-buffers nil + "An alist keeping the progress percentage per buffer. +Don't set this globally, it shall be let-bound.") + +(defun debbugs-url-display-percentage (&rest args) + "Update progress reporter." + (ignore-errors + (when (and debbugs-show-progress debbugs-progress-reporter) + ;; The fingerprint of `url-display-percentage' is FMT PERC &REST + ;; ARGS. However, there are calls which have a nil argument + ;; before the other arguments, whyever. In order to be backward + ;; compatible, we scan the arguments for the first number, and + ;; regard it as the percentage. + (while (and args (not (natnump (car args)))) + (setq args (cdr args))) + (progress-reporter-update + debbugs-progress-reporter + (and ;; There is a min value. + (aref (cdr debbugs-progress-reporter) 1) + ;; There's a percentage. + (natnump (car args)) + (let ((cell + (assq (current-buffer) debbugs-progress-reporter-buffers))) + (if (null cell) + ;; Just one buffer from synchronous call. + (car args) + ;; We must accumulate several buffer's percentage. + (setcdr cell (car args)) + (floor + (apply #'+ (mapcar (lambda (elt) (cdr elt)) + debbugs-progress-reporter-buffers)) + (length debbugs-progress-reporter-buffers))))))))) + (defun debbugs-get-bugs (&rest query) "Return a list of bug numbers which match QUERY. @@ -196,8 +237,16 @@ patch: :severity \"grave\" :status \"forwarded\" :severity \"serious\")" + (let ((debbugs-progress-reporter + (and debbugs-show-progress + (make-progress-reporter "Get bug numbers..." 0 100))) + debbugs-progress-reporter-buffers url-show-status vec kw key val) + (when debbugs-show-progress + (add-function + :override (symbol-function #'url-display-percentage) + #'debbugs-url-display-percentage + '((name . "debbugs-url-display-percentage")))) - (let (vec kw key val) ;; Check query. (while (and (consp query) (<= 2 (length query))) (setq kw (pop query) @@ -235,7 +284,13 @@ patch: (unless (null query) (error "Unknown key: %s" (car query))) - (sort (car (soap-invoke debbugs-wsdl debbugs-port "get_bugs" vec)) '<))) + (prog1 + (sort (car (soap-invoke debbugs-wsdl debbugs-port "get_bugs" vec)) '<) + (when debbugs-show-progress + (remove-function + (symbol-function #'url-display-percentage) + "debbugs-url-display-percentage") + (progress-reporter-done debbugs-progress-reporter))))) (defun debbugs-newest-bugs (amount) "Return the list of bug numbers, according to AMOUNT (a number) latest bugs." @@ -411,7 +466,16 @@ Example: (when bug-numbers ;; Retrieve bugs asynchronously. (let ((bug-ids bug-numbers) - results) + (debbugs-progress-reporter + (and debbugs-show-progress + (make-progress-reporter "Get bug information..." 0 100))) + debbugs-progress-reporter-buffers url-show-status results res) + (when debbugs-show-progress + (add-function + :override (symbol-function #'url-display-percentage) + #'debbugs-url-display-percentage + '((name . "debbugs-url-display-percentage")))) + (while bug-ids (setq results (append @@ -429,9 +493,23 @@ Example: (last bug-ids (- (length bug-ids) debbugs-max-hits-per-request)))) - (dolist (res results) - (while (buffer-live-p res) - (accept-process-output (get-buffer-process res) 0.1))))) + (when debbugs-show-progress + (dolist (res results) + (push `(,res . 0) debbugs-progress-reporter-buffers))) + + (while results + (setq res (nth (random (length results)) results)) + (if (process-live-p (get-buffer-process res)) + (accept-process-output (get-buffer-process res)) + (when debbugs-show-progress + (setcdr (assq res debbugs-progress-reporter-buffers) 100)) + (setq results (delq res results)))) + + (when debbugs-show-progress + (remove-function + (symbol-function #'url-display-percentage) + "debbugs-url-display-percentage") + (progress-reporter-done debbugs-progress-reporter)))) (append cached-bugs @@ -705,7 +783,17 @@ Examples: :operator \"NUMBT\"))" (let ((phrase (assoc :phrase query)) - args result) + (debbugs-create-progress-reporter + (and debbugs-show-progress (null debbugs-progress-reporter))) + (debbugs-progress-reporter debbugs-progress-reporter) + debbugs-progress-reporter-buffers url-show-status args result) + (when debbugs-create-progress-reporter + (setq debbugs-progress-reporter (make-progress-reporter "Query bugs...")) + (add-function + :override (symbol-function #'url-display-percentage) + #'debbugs-url-display-percentage + '((name . "debbugs-url-display-percentage")))) + (if (and phrase (not (member :skip phrase)) (not (member :max phrase))) ;; We loop, until we have all results. (let ((skip 0) @@ -723,16 +811,14 @@ Examples: query)) skip (and (= (length result1) debbugs-max-hits-per-request) (+ skip debbugs-max-hits-per-request)) - result (append result result1))) - result) + result (append result result1)))) ;; Compile search arguments. (dolist (elt query) ;; FIXME: `vec' is used in an O(N²) way. It should be a list instead, ;; on which we push elements, and we only convert it to a vector at ;; the end. - (let (vec kw key val - phrase-cond attr-cond) + (let (vec kw key val phrase-cond attr-cond) ;; Phrase is mandatory, even if empty. (when (and (or (member :skip elt) (member :max elt)) @@ -858,9 +944,17 @@ Examples: (car (soap-invoke debbugs-wsdl debbugs-port "search_est" args))) ;; The result contains lists (key value). We transform it into ;; cons cells (key . value). - (dolist (elt1 result result) + (dolist (elt1 result) (dolist (elt2 elt1) - (setcdr elt2 (cadr elt2))))))) + (setcdr elt2 (cadr elt2))))) + + (when debbugs-create-progress-reporter + (remove-function + (symbol-function #'url-display-percentage) + "debbugs-url-display-percentage") + (progress-reporter-done debbugs-progress-reporter)) + + result)) (defun debbugs-get-attribute (bug-or-message attribute) "Return the value of key ATTRIBUTE. diff --git a/packages/debbugs/debbugs.info b/packages/debbugs/debbugs.info index fdcd79c..4261dec 100644 --- a/packages/debbugs/debbugs.info +++ b/packages/debbugs/debbugs.info @@ -114,10 +114,10 @@ BTS: <https://bugs.debian.org> and <https://debbugs.gnu.org>. So if you intend to use one of these ports, you don't need to configure 'debbugs'. If you want to interact with a Debbugs port other than those listed, you have to configure 'debbugs' by adding a new server -specifier to the 'debbugs-servers' variable. The actual port can be -selected by the 'debbugs-port' variable. +specifier to the 'debbugs-servers' user option. The actual port can +be selected by the 'debbugs-port' user option. - -- Variable: debbugs-servers + -- User Option: debbugs-servers List of Debbugs server specifiers. Each entry is a list that contains a string identifying the port name and the server parameters in keyword-value form. The list initially contains @@ -145,19 +145,24 @@ selected by the 'debbugs-port' variable. :wsdl "https://bugs.foobars.net/cgi/soap.cgi?WSDL" :bugreport-url "https://bugs.foobars.net/cgi/bugreport.cgi")) - -- Variable: debbugs-port - This variable holds the name of the currently used port. The - value of the variable corresponds to the Debbugs server to be + -- User Option: debbugs-port + This user option holds the name of the currently used port. The + value of the user option corresponds to the Debbugs server to be accessed, either '"gnu.org"' or '"debian.org"', or a user defined port name. - -- Variable: debbugs-cache-expiry + -- User Option: debbugs-cache-expiry The function 'debbugs-get-status' (*note Requesting bugs statuses::) caches retrieved status entries in order to improve - the performance. This variable determines the number of seconds - an entry is cached, before it is retrieved again. A value of - 'nil' disables cache expiration, and a value of 't' disables - caching. Both values are not recommended for a usual workflow. + the performance. This user option determines the number of + seconds an entry is cached, before it is retrieved again. A + value of 'nil' disables cache expiration, and a value of 't' + disables caching. Both values are not recommended for a usual + workflow. + + -- User Option: debbugs-show-progress + If this user option is non-'nil', there is a progress report when + retrieving bugs. File: debbugs.info, Node: Requesting bug numbers, Next: Requesting bugs statuses, Prev: Configuration, Up: Top @@ -667,7 +672,7 @@ File: debbugs.info, Node: Requesting messages, Next: Requesting user tags, Pr current buffer. Note, that mbox downloading will work only if the - ':bugreport-url' field of the 'debbugs-servers' variable is + ':bugreport-url' field of the 'debbugs-servers' user option is specified (*note Configuration::). @@ -725,10 +730,10 @@ Tag Table: Node: Top1094 Node: Installation3235 Node: Configuration4336 -Node: Requesting bug numbers6691 -Node: Requesting bugs statuses12073 -Node: Searching bugs16365 -Node: Requesting messages23171 -Node: Requesting user tags26178 +Node: Requesting bug numbers6853 +Node: Requesting bugs statuses12235 +Node: Searching bugs16527 +Node: Requesting messages23333 +Node: Requesting user tags26343 End Tag Table diff --git a/packages/debbugs/debbugs.texi b/packages/debbugs/debbugs.texi index 13d0501..3066be6 100644 --- a/packages/debbugs/debbugs.texi +++ b/packages/debbugs/debbugs.texi @@ -121,10 +121,10 @@ Debbugs BTS: @uref{https://bugs.debian.org} and ports, you don't need to configure @code{debbugs}. If you want to interact with a Debbugs port other than those listed, you have to configure @code{debbugs} by adding a new server specifier to the -@code{debbugs-servers} variable. The actual port can be selected by -the @code{debbugs-port} variable. +@code{debbugs-servers} user option. The actual port can be selected +by the @code{debbugs-port} user option. -@defvar debbugs-servers +@defopt debbugs-servers List of Debbugs server specifiers. Each entry is a list that contains a string identifying the port name and the server parameters in keyword-value form. The list initially contains two predefined and @@ -153,22 +153,28 @@ Example. Add a new Debbugs port with name "foobars.net": :wsdl "https://bugs.foobars.net/cgi/soap.cgi?WSDL" :bugreport-url "https://bugs.foobars.net/cgi/bugreport.cgi")) @end example -@end defvar +@end defopt -@defvar debbugs-port -This variable holds the name of the currently used port. The value of -the variable corresponds to the Debbugs server to be accessed, either -@code{"gnu.org"} or @code{"debian.org"}, or a user defined port name. -@end defvar +@defopt debbugs-port +This user option holds the name of the currently used port. The value +of the user option corresponds to the Debbugs server to be accessed, +either @code{"gnu.org"} or @code{"debian.org"}, or a user defined port +name. +@end defopt -@defvar debbugs-cache-expiry +@defopt debbugs-cache-expiry The function @code{debbugs-get-status} (@pxref{Requesting bugs statuses}) caches retrieved status entries in order to improve the -performance. This variable determines the number of seconds an entry -is cached, before it is retrieved again. A value of @code{nil} +performance. This user option determines the number of seconds an +entry is cached, before it is retrieved again. A value of @code{nil} disables cache expiration, and a value of @code{t} disables caching. Both values are not recommended for a usual workflow. -@end defvar +@end defopt + +@defopt debbugs-show-progress +If this user option is non-@code{nil}, there is a progress report when +retrieving bugs. +@end defopt @node Requesting bug numbers @chapter Requesting bug numbers @@ -694,8 +700,8 @@ mbox. If @var{filename} is @code{nil}, the downloaded mbox is inserted into the current buffer. Note, that mbox downloading will work only if the -@code{:bugreport-url} field of the @code{debbugs-servers} variable is -specified (@pxref{Configuration}). +@code{:bugreport-url} field of the @code{debbugs-servers} user option +is specified (@pxref{Configuration}). @end defun @node Requesting user tags