From 2378e7a1529fa372c1bc9aee0373b380df6602a2 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Fri, 22 Nov 2019 11:49:27 +0100 Subject: [PATCH] Add command to show mailboxes for all currently shown reports * debbugs-gnu.el (debbugs-gnu-mode-map): Add binding for debbugs-gnu-select-current-bugs. (debbugs-gnu-select-bugs-limit-max): New defconst. Max for debbugs-gnu-select-bugs-limit. (debbugs-gnu-select-bugs-limit): New defcustom. Limits how many bugs debbugs-gnu-select-current-bugs will retrieve. (debbugs-gnu-select-current-bugs): New function. Shows mailboxes for all currently shown bugs. (debbugs-gnu-select-current-bugs-with-gnus): Implementation of mailbox retrieval using Gnus. * debbugs-ug.texi (Tabulated Lists): Add description of debbugs-gnu-select-current-bugs. --- packages/debbugs/debbugs-gnu.el | 48 +++++++++++++++++++++++++++++++- packages/debbugs/debbugs-ug.texi | 8 ++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/packages/debbugs/debbugs-gnu.el b/packages/debbugs/debbugs-gnu.el index 303b62557..a4755694d 100644 --- a/packages/debbugs/debbugs-gnu.el +++ b/packages/debbugs/debbugs-gnu.el @@ -971,6 +971,7 @@ (defvar debbugs-gnu-mode-map (set-keymap-parent map tabulated-list-mode-map) (define-key map "\r" 'debbugs-gnu-select-report) (define-key map [mouse-2] 'debbugs-gnu-select-report) + (define-key map "A" 'debbugs-gnu-select-current-bugs) (define-key map "g" 'debbugs-gnu-rescan) (define-key map "R" 'debbugs-gnu-show-all-blocking-reports) (define-key map "C" 'debbugs-gnu-send-control-message) @@ -990,10 +991,14 @@ (defvar debbugs-gnu-mode-map (define-key menu-map [debbugs-gnu-select-report] '(menu-item "Show Reports" debbugs-gnu-select-report :help "Show all reports belonging to this bug")) + (define-key-after menu-map [debbugs-gnu-select-current] + '(menu-item "Show Reports For All" debbugs-gnu-select-current-bugs + :help "Show reports for all currently shown bugs") + 'debbugs-gnu-select-report) (define-key-after menu-map [debbugs-gnu-rescan] '(menu-item "Refresh Bugs" debbugs-gnu-rescan :help "Refresh bug list") - 'debbugs-gnu-select-report) + 'debbugs-gnu-select-current) (define-key-after menu-map [debbugs-gnu-show-all-blocking-reports] '(menu-item "Show Release Blocking Bugs" debbugs-gnu-show-all-blocking-reports @@ -1399,6 +1404,47 @@ (defun debbugs-read-emacs-bug-with-rmail (id status merged) (define-key rmail-mode-map "E" 'debbugs-gnu-make-control-message) (rmail-show-message 1))) +(defconst debbugs-gnu-select-bugs-limit-max 50) +(defcustom debbugs-gnu-select-bugs-limit 10 + "Maximum number of bugs to retrieve for Gnus group. +This applies for `debbugs-gnu-select-current-bugs. +Maximum allowed value is 50 to avoid overloading the server." + :type '(integer + :validate + (lambda (widget) + (unless (<= 1 + (widget-value widget) + debbugs-gnu-select-bugs-limit-max) + (widget-put widget :error + "Invalid value: range is 1..50")))) + :version "27.1") + +(defun debbugs-gnu-select-current-bugs () + "Retrieve the mailboxes for all currently shown bugs. +Limited by `debbugs-gnu-select-bugs-limit'." + (interactive) + (unless (eq debbugs-gnu-mail-backend 'gnus) + (error "This function only works with Gnus.")) + (debbugs-gnu-select-current-bugs-with-gnus)) + +(defun debbugs-gnu-select-current-bugs-with-gnus () + "Create a Gnus group of the messages from the currently shown bugs." + (save-excursion + (let ((mbox-url + (replace-regexp-in-string + ";mboxstat=yes" "" + (alist-get 'emacs gnus-bug-group-download-format-alist) + nil t)) + ids) + (goto-char (point-min)) + (dotimes (i debbugs-gnu-select-bugs-limit) + (push (debbugs-gnu-current-id t) ids) + (push (cdr (assq 'mergedwith (debbugs-gnu-current-status))) ids) + (forward-line 1)) + (setq ids (delete nil (nreverse ids))) + (gnus-read-ephemeral-bug-group ids mbox-url) + (debbugs-gnu-summary-mode 1)))) + (defcustom debbugs-gnu-lars-workflow nil "If non-nil, set some Gnus vars as preferred by Lars." :type 'boolean diff --git a/packages/debbugs/debbugs-ug.texi b/packages/debbugs/debbugs-ug.texi index 8121f7bf8..6e86194e5 100644 --- a/packages/debbugs/debbugs-ug.texi +++ b/packages/debbugs/debbugs-ug.texi @@ -373,6 +373,14 @@ Show the email messages that discuss the bug. @* @item +@kindex @kbd{A} +@kbd{A} @tab +@code{debbugs-gnu-select-current-bugs} @* +Show the email messages for all currently displayed messages +(including merged reports). Limited by user option +@code{debbugs-gnu-select-bugs-limit}. + +@item @kindex @kbd{d} @kbd{d} @tab @code{debbugs-gnu-display-status} @* -- 2.24.0.155.gd9f6f3b619