all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Morgan Smith <Morgan.J.Smith@outlook.com>
To: 64064@debbugs.gnu.org
Cc: Michael Albinus <michael.albinus@gmx.de>
Subject: bug#64064: [PATCH 0/4] debbugs improvements
Date: Wed, 14 Jun 2023 08:15:57 -0400	[thread overview]
Message-ID: <DM5PR03MB31632E3A4FE170C62E7D4B0CC55AA@DM5PR03MB3163.namprd03.prod.outlook.com> (raw)

[-- 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


             reply	other threads:[~2023-06-14 12:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 12:15 Morgan Smith [this message]
2023-06-16  8:50 ` bug#64064: [PATCH 0/4] debbugs improvements 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM5PR03MB31632E3A4FE170C62E7D4B0CC55AA@DM5PR03MB3163.namprd03.prod.outlook.com \
    --to=morgan.j.smith@outlook.com \
    --cc=64064@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.