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: Michael Albinus <michael.albinus@gmx.de>
Cc: 64064@debbugs.gnu.org
Subject: bug#64064: [PATCH 2/4] Don't error out on 'nil' alist value.
Date: Fri, 16 Jun 2023 12:49:45 -0400	[thread overview]
Message-ID: <DM5PR03MB31633402D0A914CCDAB72129C558A@DM5PR03MB3163.namprd03.prod.outlook.com> (raw)
In-Reply-To: <87ilbnn1vb.fsf@gmx.de> (Michael Albinus's message of "Fri, 16 Jun 2023 12:22:00 +0200")

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

Michael Albinus <michael.albinus@gmx.de> writes:

> Couldn't we simply fix this in 'debbugs-gnu-sort-submitter' and
> 'debbugs-gnu-sort-title'? That is, handling a nil value for submitter
> and title?
>
> And do you have an example bug number where this could happen?

You are correct.  I have no example and I doubt such a bug exists.  We
could remove that part of this patch.  Although it is odd that the
DEFAULT argument to alist-get is set in that case.

On a related note, bug#60850 does not have a subject line so here is
more complete patch:


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

From e391f728c3a00215d8d32ac9b54b29961da46774 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] 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-sort-submitter, debbugs-gnu-sort-title):
Remove DEFAULT argument of alist-get and instead wrap call with 'or' to return
default.

* debbugs-org.el (debbugs-org-show-reports): If the subject is empty, use the
empty string.
---
 debbugs-gnu.el | 12 ++++++------
 debbugs-org.el |  5 ++---
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index 81297d8b7f..dae87c75b0 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -1282,10 +1282,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))
@@ -1303,14 +1303,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)
diff --git a/debbugs-org.el b/debbugs-org.el
index 3d353c81e4..c3786d3b0e 100644
--- a/debbugs-org.el
+++ b/debbugs-org.el
@@ -209,9 +209,8 @@ marked as \"client-side filter\"."
 	     (archived (alist-get 'archived status))
 	     (tags (append (alist-get 'found_versions status)
 			   (alist-get 'tags status)))
-	     (subject (when (alist-get 'subject status)
-			(decode-coding-string
-			 (alist-get 'subject status) 'utf-8)))
+	     (subject (decode-coding-string
+			       (or (alist-get 'subject status) "") 'utf-8))
 	     (date (alist-get 'date status))
 	     (last-modified (alist-get 'last_modified status))
 	     (originator (when (alist-get 'originator status)
-- 
2.40.1


[-- Attachment #3: Type: text/plain, Size: 8 bytes --]


Morgan

  reply	other threads:[~2023-06-16 16:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=DM5PR03MB31633402D0A914CCDAB72129C558A@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.