From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.help Subject: Re: A few questions about debbugs Date: Wed, 28 Aug 2024 13:42:12 +0200 Message-ID: <87frqolvqj.fsf@gmx.de> References: <871q2uelx6.fsf@thaodan.de> <87r0as992a.fsf@gmx.de> <87msl83hbe.fsf@gmx.de> <874j7e2rlg.fsf@gmx.de> <87ttfc3h7d.fsf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24843"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier , =?utf-8?Q?Bj=C3=B6rn?= Bidar To: Stefan Monnier via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 28 13:43:22 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sjH57-0006JB-Ur for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 28 Aug 2024 13:43:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjH4D-0004M4-QS; Wed, 28 Aug 2024 07:42:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sjH4B-0004Kz-8V for help-gnu-emacs@gnu.org; Wed, 28 Aug 2024 07:42:23 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sjH48-0004ku-Ej for help-gnu-emacs@gnu.org; Wed, 28 Aug 2024 07:42:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1724845334; x=1725450134; i=michael.albinus@gmx.de; bh=aO1cJKLU8SEjZn8ohT58ngtRSLnREBkxGLq3VyQ4Scs=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=LiPEi+76JdkI9kRei1w+TbhvBZrCfC6wqeTdtbb9d0SN2yvQNJTyQipdGS6yztNh va4ke/6VzT2QntOap+TeiFFoBRauHtygbRRcxwQhOragECFqNdoEu2iuzT1/l2TdZ zdTlCSC3LAurXqbNnqLioAA6MOMoEoPkkzQe8RpxwRlnt/K9UuP23Wg42fjf7pElG rPAMOKlCZjvybqLwRbGN/zty39GlSy8vqYmToArvyUzUinKWG0+T0l5QP/XXls3b2 /RO7/iUSqmCxc7XwhEj1DIYkOmnlnk2aVP+vcUIA2Menfnn2M+MvxvBUP8O+fhTMV EScoQn+osfZoXYDUrA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MWRRT-1sbxl70sVX-00SBGx; Wed, 28 Aug 2024 13:42:14 +0200 In-Reply-To: <87ttfc3h7d.fsf@gmx.de> (Michael Albinus's message of "Fri, 23 Aug 2024 10:00:53 +0200") X-Provags-ID: V03:K1:O26ahcyKEaNNN/edYnmXRM9+mf4JR0UbSjxwfo74w7m70iRa4nj YqyOPXcra03C7qjzV1PJxl1o0J/dbi1rqODa2ntzwBrsc1btGK2yF/dPyO+mEXaz6Dr/GkD 5SmopLPr0RkbNh3M5MZ2RhaD1Ijx+ujKageZkUIatfpL8XhxVnbKyG+dzToHBRbtLPFKNMH tab64mNQjw6yida4YqSPg== UI-OutboundReport: notjunk:1;M01:P0:LwFTHpSRcP0=;N++Ma+E6XRDY7UI6nFnM6ZdKOKV MpU4TPsNogH86SJupz8a1g16RFfjsEtIsyEz4vNZncEpvawWo90c62MgCBzBUIfkU5emxsXmi MTyoectJCfGi44MvO2GvipLaTtr8gNUi27sMjItfIN+g0nE7TCFk5LPWuDBZKhnqaAhvKoAo1 yrhRfFhQZjkEHlPwMxOYUIGyBej+CTTVszFU9lO85mjhtzypfsg7HBW5STUOymj8IZs2vhSVY XDpEiXqo75qGR1v631HUxXH6tRFvR1bR3l6SsP92+85Q97ejnEpIIF86cJzep9x2mPaoiX5oD jCuFRfdi1A5JxFjC7lQJBaU5GDaXr7LqD4+l5ndFn+mM57YjcnDckKha8iog085yaMpt35G1W hsdICY3Kg+QkzULL4Cqb+Mpe2PFJceHbXSQt1Got6LuGqgUhvf+gPSaYIHohdsovdgW4wml+b icaEjlq/yOc0cfVQejzKTgpmb8oUV9gPoBMpnhFufsav0wGsyHPMYhmSKnwRDe1CeHu8Bsqsl xH1lXCZfwKt1UemYWHLYtVKy38A7LiJHaHlHYigKO6LLOgF+ZdOHYRBLrr04PzWEystf2dlaY gt/sZlp2js1dI2QkMgSAO/3HLkBnJWX7X+D0N2I5NQ1lw69ySKXALpp9TF1tG4/g21/hkQN4N kFYkRIg/q8L1jArgeaUMj0MQeDFQkvx+7pl+PRXiSRq00VKT3whz7FJnJ49dmEX97px62VUV/ FZrs4mYutQg3nYc0hosmVecoGw0gFS92LOWYJinSZU/2GT/294IF4quimJyRUmJwXafmW914 Received-SPF: pass client-ip=212.227.17.21; envelope-from=michael.albinus@gmx.de; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147839 Archived-At: --=-=-= Content-Type: text/plain Michael Albinus writes: Hi, >>> Replacing soap-invoke by soap-invoke-async is not a problem. What I >>> worry about is the UI. If you invoke debbugs-search, and you do >>> something else in Emacs then, you need a proper way how to present the >>> search results to the user w/o interrupting the work she is doing >>> meanwhile. >> >> Indeed displaying the buffer asynchronously is too disruptive. >> >> The usual way to do that in Emacs is to immediately display the (empty) >> result buffer and then maybe emit a `message` when this buffer has >> been filled. > > Thanks for the explanation. I'll give it a try for debbugs-{gnu,org}-search. I've assembled a proof-of-concept for debbugs-gnu-search, see appended patch. It is on top of the ELPA git repository, but it might apply also on the last distributed debbugs release (didn't check). Feedback appreciated. Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/debbugs-gnu.el b/debbugs-gnu.el index 68599cff7f..5acb10af16 100644 =2D-- a/debbugs-gnu.el +++ b/debbugs-gnu.el @@ -457,6 +457,9 @@ a date, value is the cons cell (BEFORE . AFTER).") The specification which bugs shall be suppressed is taken from `debbugs-gnu-default-suppress-bugs'.") +(defvar debbugs-gnu-current-buffer nil + "The current buffer results are presented in.") + (defvar debbugs-gnu-current-print-function #'tabulated-list-print "Which function to apply printing the tabulated list.. See `debbugs-gnu-package' for an alternative.") @@ -680,8 +683,12 @@ depend on PHRASE being a string, or nil. See Info no= de elt)) ;; Do the search. - (debbugs-gnu severities packages archivedp) - (message "Search finished")) + (make-thread + (lambda () + (debbugs-gnu severities packages archivedp) + (message + (substitute-command-keys + "Search finished, visit buffer via \\[debbugs-gnu-show-last-result= ]"))))) ;;;###autoload (defun debbugs-gnu-patches () @@ -855,6 +862,13 @@ This function assumes the variable `user-mail-address= ' is defined." (interactive) (apply #'debbugs-gnu-bugs (debbugs-get-bugs :submitter "me" :status "op= en"))) +;;;###autoload +(defun debbugs-gnu-show-last-result () + "Switch to buffer with the recent retrieved bugs" + (interactive) + (when (ignore-errors (get-buffer debbugs-gnu-current-buffer)) + (pop-to-buffer-same-window debbugs-gnu-current-buffer))) + (defun debbugs-gnu-get-bugs (query) "Retrieve bug numbers from debbugs.gnu.org according search criteria." (let* ((bugs (assq 'bugs query)) @@ -874,7 +888,18 @@ This function assumes the variable `user-mail-address= ' is defined." (if phrase (cond ((eq (car elt) 'phrase) - (list (list :phrase (cdr elt)))) + (let ((str (cdr elt)) + res) + (while (string-match + (rx (1+ space) (group (or "MAX" "SKIP")) + (1+ space) (group (1+ digit)) eol) + str) + (push (string-to-number (match-string 2 str)) re= s) + (push + (intern (concat ":" (downcase (match-string 1 s= tr)))) + res) + (setq str (replace-match "" nil nil str))) + (list (append (list :phrase str) res)))) ((memq (car elt) '(date @cdate)) (list (list (intern (concat ":" (symbol-name (car elt)))) (cddr elt) (cadr elt) @@ -918,19 +943,21 @@ This function assumes the variable `user-mail-addres= s' is defined." If OFFLINE is non-nil, the query is not sent to the server. Bugs are taken from the cache instead." (let* ((inhibit-read-only t) - string - (buffer-name + string) + (setq debbugs-gnu-current-buffer (cond ((setq string (alist-get 'phrase debbugs-gnu-current-query)) (format "*%S Bugs*" string)) ((setq string (alist-get 'package debbugs-gnu-current-query)) (format "*%s Bugs*" (capitalize string))) - (t "*Bugs*")))) + (t "*Bugs*"))) ;; The tabulated mode sets several local variables. We must get ;; rid of them. - (when (get-buffer buffer-name) - (kill-buffer buffer-name)) - (pop-to-buffer-same-window (get-buffer-create buffer-name)) + (when (get-buffer debbugs-gnu-current-buffer) + (kill-buffer debbugs-gnu-current-buffer)) + (funcall + (if (debbugs-show-progress) #'pop-to-buffer-same-window #'set-buffer= ) + (get-buffer-create debbugs-gnu-current-buffer)) (debbugs-gnu-mode) ;; Print bug reports. diff --git a/debbugs.el b/debbugs.el index 627cdf163d..b04256a243 100644 =2D-- a/debbugs.el +++ b/debbugs.el @@ -135,6 +135,11 @@ OPERATION-NAME and PARAMETERS are as described in `so= ap-invoke'." "Whether progress report is shown." :type 'boolean) +(defun debbugs-show-progress () + "Whether progress report is shown." + (and debbugs-show-progress + (or (not main-thread) (eq main-thread (current-thread))))) + (defvar debbugs-progress-reporter nil "The progress reporter. Don't set this globally, it shall be let-bound.") @@ -154,7 +159,7 @@ Don't set this globally, it shall be let-bound.") (defun debbugs-url-display-message-or-percentage (&rest args) "Update progress reporter." (ignore-errors - (when (and debbugs-show-progress debbugs-progress-reporter) + (when (and (debbugs-show-progress) debbugs-progress-reporter) ;; The fingerprint of `url-display-percentage' is FMT PERC &REST ;; ARGS. Since Emacs 29.1, this is obsolete and replaced by ;; `url-display-message', which should also carry the percentage @@ -256,10 +261,10 @@ patch: :status \"forwarded\" :severity \"serious\")" (let ((debbugs-progress-reporter - (and debbugs-show-progress + (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 + (when (debbugs-show-progress) (add-function :override (symbol-function debbugs-url-display-message-or-percentage-functio= n) @@ -305,7 +310,7 @@ patch: (error "Unknown key: %s" (car query))) (prog1 (sort (car (soap-invoke debbugs-wsdl debbugs-port "get_bugs" vec)) #'<) - (when debbugs-show-progress + (when (debbugs-show-progress) (remove-function (symbol-function debbugs-url-display-message-or-percentage-function) "debbugs-url-display-message-or-percentage") @@ -486,10 +491,10 @@ Example: ;; Retrieve bugs asynchronously. (let ((bug-ids bug-numbers) (debbugs-progress-reporter - (and debbugs-show-progress + (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 + (when (debbugs-show-progress) (add-function :override (symbol-function debbugs-url-display-message-or-percentage-fun= ction) @@ -513,7 +518,7 @@ Example: (last bug-ids (- (length bug-ids) debbugs-max-hits-per-request)))) - (when debbugs-show-progress + (when (debbugs-show-progress) (dolist (res results) (push `(,res . 0) debbugs-progress-reporter-buffers))) @@ -521,11 +526,11 @@ Example: (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 + (when (debbugs-show-progress) (setcdr (assq res debbugs-progress-reporter-buffers) 100)) (setq results (delq res results)))) - (when debbugs-show-progress + (when (debbugs-show-progress) (remove-function (symbol-function debbugs-url-display-message-or-percentage-function) "debbugs-url-display-message-or-percentage") @@ -803,7 +808,7 @@ Examples: (let ((phrase (assq :phrase query)) (debbugs-create-progress-reporter - (and debbugs-show-progress (null debbugs-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 --=-=-=--