unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64064: [PATCH 0/4] debbugs improvements
@ 2023-06-14 12:15 Morgan Smith
  2023-06-16  8:50 ` Michael Albinus
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Morgan Smith @ 2023-06-14 12:15 UTC (permalink / raw)
  To: 64064; +Cc: Michael Albinus

[-- Attachment #1: Type: text/plain, Size: 722 bytes --]

Hello!

These patches enable the use of some more 'tabulated-list' functions
like 'tabulated-list-sort' (bound to "S").

You may or may not want to install the last patch.  It does add
potential network calls to the 'revert-buffer' function.  If there are
legitimate reasons to revert the buffer without fetching new bugs then
people might not like that change.

Morgan Smith (4):
  Call 'tabulated-list-print-entry' in 'debbugs-gnu-print-entry'.
  Don't error out on 'nil' alist value.
  Don't sort bugs in 'debbugs-gnu-show-reports'.
  Add 'debbugs-gnu-rescan' to 'tabulated-list-revert-hook'.

 debbugs-gnu.el | 62 +++++++++-----------------------------------------
 1 file changed, 11 insertions(+), 51 deletions(-)
 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Call-tabulated-list-print-entry-in-debbugs-gnu-print.patch --]
[-- Type: text/x-patch, Size: 2908 bytes --]

From f64d98ea82cfc999fc6eb644696dc2a0f6f100ec Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Mon, 12 Jun 2023 20:12:11 -0400
Subject: [PATCH 1/4] Call 'tabulated-list-print-entry' in
 'debbugs-gnu-print-entry'.

Some of the features of 'tabulated-list' (tabulated-list-next-column,
tabulated-list-sort) didn't work properly because 'debbugs-gnu-print-entry'
didn't set the 'tabulated-list-column-name' text property.  Instead of trying
to duplicate code we can simply call 'tabulated-list-print-entry'.

* debbugs-gnu.el (debbugs-gnu-print-entry): Remove all printing logic and
replace with a call to 'tabulated-list-print-entry'.
---
 debbugs-gnu.el | 40 ++--------------------------------------
 1 file changed, 2 insertions(+), 38 deletions(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index 337c7cbb9a..2c76a3361b 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -1052,18 +1052,7 @@ are taken from the cache instead."
 (defun debbugs-gnu-print-entry (list-id cols)
   "Insert a debbugs entry at point.
 Used instead of `tabulated-list-print-entry'."
-  (let ((beg (point))
-	(pos 0)
-	(case-fold-search t)
-	(id               (aref cols 0))
-	(id-length        (nth 1 (aref tabulated-list-format 0)))
-	(state            (aref cols 1))
-	(state-length     (nth 1 (aref tabulated-list-format 1)))
-	(submitter        (aref cols 2))
-	(submitter-length (nth 1 (aref tabulated-list-format 2)))
-	(title            (aref cols 3))
-	;; (title-length     (nth 1 (aref tabulated-list-format 3)))
-        )
+  (let ((case-fold-search t))
     (when (and
 	   ;; We may have a narrowing in effect.
 	   (or (not debbugs-gnu-limit)
@@ -1090,32 +1079,7 @@ Used instead of `tabulated-list-print-entry'."
 				       (> (cddr check) val)))
 			  (throw :suppress t))))))))
 
-      ;; Insert id.
-      (indent-to (- id-length (length id)))
-      (insert id)
-      ;; Insert state.
-      (indent-to (setq pos (+ pos id-length 1)) 1)
-      (insert (if (> (length state) state-length)
-		  (propertize (substring state 0 state-length)
-			      'help-echo state)
-		state))
-      ;; Insert submitter.
-      (indent-to (setq pos (+ pos state-length 1)) 1)
-      (insert (if (> (length submitter) submitter-length)
-		  (propertize (substring submitter 0 submitter-length)
-			      'help-echo submitter)
-		submitter))
-      (indent-to (+ pos (1- submitter-length)))
-      ;; Insert title.
-      (indent-to (setq pos (+ pos submitter-length 1)) 1)
-      (insert (propertize title 'help-echo title))
-      ;; Add properties.
-      (add-text-properties
-       beg (point)
-       `(tabulated-list-id ,list-id
-	 tabulated-list-entry ,cols
-	 mouse-face highlight))
-      (insert ?\n))))
+      (tabulated-list-print-entry list-id cols))))
 
 (defun debbugs-gnu-menu-map-emacs-enabled ()
   "Whether \"Show Release Blocking Bugs\" is enabled in the menu."
-- 
2.40.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Don-t-error-out-on-nil-alist-value.patch --]
[-- Type: text/x-patch, Size: 2936 bytes --]

From 54a3e56379308c05a9ac6646160d136a26044b95 Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Mon, 12 Jun 2023 19:56:50 -0400
Subject: [PATCH 2/4] Don't error out on 'nil' alist value.

The intention of the DEFAULT argument to alist-get is to return "" instead of
'nil'.  However, this still returns 'nil' if the key exists but the value is
'nil'.

This problem wasn't detected previously since the functions
'debbugs-gnu-sort-submitter' and 'debbugs-gnu-sort-title' weren't actually
used until the previous commit.

* debbugs-gnu.el (debbugs-gnu-print-entry):
(debbugs-gnu-sort-submitter):
(debbugs-gnu-sort-title):
Remove DEFAULT argument of alist-get and instead wrap call with 'or' to return
default.
---
 debbugs-gnu.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index 2c76a3361b..c28a4aa5e4 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -1062,7 +1062,7 @@ Used instead of `tabulated-list-print-entry'."
 	       (not (catch :suppress
 		      (dolist (check debbugs-gnu-default-suppress-bugs)
 			(when (string-match
-			       (cdr check) (alist-get (car check) list-id ""))
+			       (cdr check) (or (alist-get (car check) list-id) ""))
 			  (throw :suppress t))))))
 	   ;; Filter search list.
 	   (not (catch :suppress
@@ -1288,10 +1288,10 @@ Interactively, it is non-nil with the prefix argument."
 (defun debbugs-gnu-sort-submitter (s1 s2)
   (let ((address1
 	 (debbugs-gnu--split-address
-	  (decode-coding-string (alist-get 'originator (car s1) "") 'utf-8)))
+	  (decode-coding-string (or (alist-get 'originator (car s1)) "") 'utf-8)))
 	(address2
 	 (debbugs-gnu--split-address
-	  (decode-coding-string (alist-get 'originator (car s2) "") 'utf-8))))
+	  (decode-coding-string (or (alist-get 'originator (car s2)) "") 'utf-8))))
     (cond
      ;; Bugs I'm the originator of go to the beginning.
      ((and (string-equal user-mail-address (car address1))
@@ -1309,14 +1309,14 @@ Interactively, it is non-nil with the prefix argument."
 (defun debbugs-gnu-sort-title (s1 s2)
   (let ((owner1
 	 (car (debbugs-gnu--split-address
-	       (decode-coding-string (alist-get 'owner (car s1) "") 'utf-8))))
+	       (decode-coding-string (or (alist-get 'owner (car s1)) "") 'utf-8))))
 	(subject1
-	 (decode-coding-string (alist-get 'subject (car s1) "") 'utf-8))
+	 (decode-coding-string (or (alist-get 'subject (car s1)) "") 'utf-8))
 	(owner2
 	 (car (debbugs-gnu--split-address
-	       (decode-coding-string (alist-get 'owner (car s2) "") 'utf-8))))
+	       (decode-coding-string (or (alist-get 'owner (car s2)) "") 'utf-8))))
 	(subject2
-	 (decode-coding-string (alist-get 'subject (car s2) "") 'utf-8)))
+	 (decode-coding-string (or (alist-get 'subject (car s2)) "") 'utf-8)))
     (cond
      ;; Bugs I'm the owner of go to the beginning.
      ((and (string-equal user-mail-address owner1)
-- 
2.40.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Don-t-sort-bugs-in-debbugs-gnu-show-reports.patch --]
[-- Type: text/x-patch, Size: 1427 bytes --]

From 550385aeb852ad30bb18d341d475f65ec613fdaf Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Mon, 12 Jun 2023 20:13:53 -0400
Subject: [PATCH 3/4] Don't sort bugs in 'debbugs-gnu-show-reports'.

Everything is automatically sorted by 'tabulated-list-mode' according to
'tabulated-list-sort-key' which we already set to the id.

* debbugs-gnu.el (debbugs-gnu-show-reports): Don't sort the bugs.
---
 debbugs-gnu.el | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index c28a4aa5e4..c65ea3e827 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -923,7 +923,6 @@ are taken from the cache instead."
 
     ;; Print bug reports.
     (dolist (status
-	     (sort
 	      (let ((debbugs-cache-expiry (if offline nil debbugs-cache-expiry))
 		    ids)
 		(apply #'debbugs-get-status
@@ -933,11 +932,7 @@ are taken from the cache instead."
 					(push key ids))
 				      debbugs-cache-data)
 			     ids)
-			 (debbugs-gnu-get-bugs debbugs-gnu-local-query))))
-	      ;; Sort so that if a new report gets merged with an old
-	      ;; report, it shows up under the new report.
-	      (lambda (s1 s2)
-		(> (alist-get 'id s1) (alist-get 'id s2)))))
+			 (debbugs-gnu-get-bugs debbugs-gnu-local-query)))))
       (let* ((id (alist-get 'id status))
 	     (words (cons (alist-get 'severity status)
 			  (alist-get 'keywords status)))
-- 
2.40.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-Add-debbugs-gnu-rescan-to-tabulated-list-revert-hook.patch --]
[-- Type: text/x-patch, Size: 973 bytes --]

From 5526b57121df84a9db6fd8f14771b01ee2e2cddc Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Mon, 12 Jun 2023 20:18:38 -0400
Subject: [PATCH 4/4] Add 'debbugs-gnu-rescan' to 'tabulated-list-revert-hook'.

This now fetches new bugs when the buffer is reverted.

* debbugs-gnu.el (debbugs-gnu-mode): Add 'debbugs-gnu-rescan' to
'tabulated-list-revert-hook'.
---
 debbugs-gnu.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index c65ea3e827..df651f3f2f 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -1221,6 +1221,7 @@ Interactively, it is non-nil with the prefix argument."
 			       ("Title"     10 debbugs-gnu-sort-title)])
   (setq tabulated-list-sort-key (cons "Id" nil))
   (setq tabulated-list-printer #'debbugs-gnu-print-entry)
+  (add-hook 'tabulated-list-revert-hook #'debbugs-gnu-rescan nil t)
   (buffer-disable-undo)
   (setq truncate-lines t)
   (setq buffer-read-only t))
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-06-19  7:40 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14 12:15 bug#64064: [PATCH 0/4] debbugs improvements Morgan Smith
2023-06-16  8:50 ` Michael Albinus
     [not found]   ` <DM5PR03MB3163BD5C32B57C2C6860B7B6C558A@DM5PR03MB3163.namprd03.prod.outlook.com>
2023-06-16 16:57     ` Morgan Smith
2023-06-16 17:04       ` Michael Albinus
2023-06-16 10:16 ` bug#64064: [PATCH 1/4] Call 'tabulated-list-print-entry' in 'debbugs-gnu-print-entry' Michael Albinus
2023-06-18 10:11   ` bug#64064: [PATCH 0/4] debbugs improvements Michael Albinus
2023-06-18 19:26     ` Morgan Smith
2023-06-16 10:22 ` bug#64064: [PATCH 2/4] Don't error out on 'nil' alist value Michael Albinus
2023-06-16 16:49   ` Morgan Smith
2023-06-18 11:14     ` Michael Albinus
2023-06-16 10:26 ` bug#64064: [PATCH 3/4] Don't sort bugs in 'debbugs-gnu-show-reports' Michael Albinus
2023-06-16 16:56   ` Morgan Smith
2023-06-18 11:52     ` Michael Albinus
2023-06-18 19:22       ` Morgan Smith
2023-06-19  7:40         ` Michael Albinus
2023-06-16 10:34 ` bug#64064: [PATCH 4/4] Add 'debbugs-gnu-rescan' to 'tabulated-list-revert-hook' Michael Albinus
2023-06-18 11:50   ` Michael Albinus
2023-06-16 10:37 ` bug#64064: [PATCH 0/4] debbugs improvements Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).