Subject: Re: bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration

From: Eric Abrahamsen <[email-masked]>
Date: Wed, 26 Aug 2020 18:19:32 -0700

On 08/25/20 21:37 PM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <[email-masked]> writes:
>
>> Okay, I see. But even given that, leaving `gnus-server-set-status'
>> alone, it might be fine to have `gnus-close-server' set a 'closed status
>> -- the server will just re-set it afterwards.
>
> Sure.  I haven't looked at all the callers, though, but I guess it's a
> simplification.

I think it's more a matter of reducing confusion for hackers. If I do
`gnus-close-server' followed by `gnus-server-status', it tells me the
server is open -- not very helpful.

The patch is pretty simple.

diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index 97e10a37a2..d613bc86ad 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -4300,8 +4300,7 @@ gnus-group-suspend
     ;; Closing all the backends is useful (for instance) when when the
     ;; IP addresses have changed and you need to reconnect.
     (dolist (elem gnus-opened-servers)
-      (gnus-close-server (car elem))
-      (setcar (cdr elem) 'closed))
+      (gnus-close-server (car elem)))
     (when group-buf
       (bury-buffer group-buf)
       (delete-windows-on group-buf t))))
diff --git a/lisp/gnus/gnus-int.el b/lisp/gnus/gnus-int.el
index 60ebc07c34..da385a1802 100644
--- a/lisp/gnus/gnus-int.el
+++ b/lisp/gnus/gnus-int.el
@@ -351,9 +351,12 @@ gnus-close-server
   "Close the connection to GNUS-COMMAND-METHOD."
   (when (stringp gnus-command-method)
     (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
-  (funcall (gnus-get-function gnus-command-method 'close-server)
-	   (nth 1 gnus-command-method)
-	   (nthcdr 2 gnus-command-method)))
+  (prog1
+      (funcall (gnus-get-function gnus-command-method 'close-server)
+	       (nth 1 gnus-command-method)
+	       (nthcdr 2 gnus-command-method))
+    (when-let ((elem (assoc gnus-command-method gnus-opened-servers)))
+      (setf (nth 1 elem) 'closed))))
 
 (defun gnus-request-list (gnus-command-method)
   "Request the active file from GNUS-COMMAND-METHOD."