Subject: bug#37590: 27.0.50; gnus-group-set-info setcdr exception

From: dick <[email-masked]>
Date: Wed, 02 Oct 2019 15:10:54 -0400

>From 92862ab4d7e9f8400229add13a6e16e437d6dbd3 Mon Sep 17 00:00:00 2001
From: dickmao <none>
Date: Wed, 2 Oct 2019 14:22:26 -0400
Subject: [PATCH] Avoid setcdr exception when gnus-newsrc-alist is empty

Exception occurs when using debbugs-gnu.
* lisp/gnus/gnus-group.el (gnus-group-set-info): check if
  gnus-newsrc-alist is a consp
---
 lisp/gnus/gnus-group.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index 915125b655..bca5d35f24 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -4466,11 +4466,14 @@ gnus-group-set-info
 			     (gnus-list-of-unread-articles (car info)))))
 	    ;; The above `setcar' will only affect the hashtable, not
 	    ;; the alist: update the alist separately.
-	    (push info (cdr (setq gnus-newsrc-alist
-				   (remove (assoc-string
-					    (gnus-info-group info)
-					    gnus-newsrc-alist)
-					   gnus-newsrc-alist)))))
+            (setf (alist-get (car info)
+                             ;; avoid usurping dummy info at the head
+                             ;; of gnus-newsrc-alist
+                             (if (consp gnus-newsrc-alist)
+                                 (cdr gnus-newsrc-alist)
+                               gnus-newsrc-alist)
+                             nil nil #'equal)
+                  (cdr info)))
 	(error "No such group: %s" (gnus-info-group info))))))
 
 ;; Ad-hoc function for inserting data from a different newsrc.eld
-- 
2.23.0