unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
@ 2020-08-21 20:43 Eric Abrahamsen
  2020-08-22  6:33 ` Eli Zaretskii
  2020-08-22 13:53 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 12+ messages in thread
From: Eric Abrahamsen @ 2020-08-21 20:43 UTC (permalink / raw)
  To: 42977

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


The attached patch provides a new gnus-dbus.el library, allowing systems
with dbus support to register a signal that closes all Gnus servers when
the system is going down for sleep. This is kind of a stop-gap solution
for the larger problems discussed in #40748.

It only does anything if Emacs has been compiled with dbus support, and
if the user sets the `gnus-dbus-close-on-sleep' to non-nil (it defaults
to nil).

Right now I've done this by checking the value of that option in
`gnus-1', but I could just as easily have the library add a startup
hook.

I assume this would require a mention in the manual. Is it something
we'd add to NEWS, as well?

Thanks,
Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-basic-D-Bus-integration-to-Gnus.patch --]
[-- Type: text/x-patch, Size: 4296 bytes --]

From 414051f4fb7d60a6674b7267dc7f73025ddb1a3b Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Fri, 21 Aug 2020 13:36:58 -0700
Subject: [PATCH] Add basic D-Bus integration to Gnus

* lisp/gnus/gnus-dbus.el: New library, registering a signal that
closes all Gnus servers when the system is going to sleep.
* lisp/gnus/gnus-start.el: Check new option
`gnus-dbus-close-on-sleep', and register the appropriate D-Bus signal
if it is non-nil.
* lisp/gnus/gnus.el: New gnus-dbus customization group.
---
 lisp/gnus/gnus-dbus.el  | 66 +++++++++++++++++++++++++++++++++++++++++
 lisp/gnus/gnus-start.el |  3 ++
 lisp/gnus/gnus.el       |  4 +++
 3 files changed, 73 insertions(+)
 create mode 100644 lisp/gnus/gnus-dbus.el

diff --git a/lisp/gnus/gnus-dbus.el b/lisp/gnus/gnus-dbus.el
new file mode 100644
index 0000000000..14f0abb6be
--- /dev/null
+++ b/lisp/gnus/gnus-dbus.el
@@ -0,0 +1,66 @@
+;;; gnus-dbus.el --- DBUS integration for Gnus       -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020  Free Software Foundation, Inc.
+
+;; Author: Eric Abrahamsen <eric@ericabrahamsen.net>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library contains some Gnus integration for systems using DBUS.
+;; At present it registers a signal to close all Gnus servers before
+;; system sleep or hibernation.
+
+;;; Code:
+
+(require 'dbus)
+
+(defcustom gnus-dbus-close-on-sleep nil
+  "When non-nil, close Gnus servers on system sleep."
+  :group 'gnus-dbus
+  :type 'boolean)
+
+(defvar gnus-dbus-sleep-registration-object nil
+  "Object returned from `dbus-register-signal'.
+Used to unregistering the signal.")
+
+(defun gnus-dbus-register-sleep-signal ()
+  "Use `dbus-register-signal' to close servers on sleep."
+  (when (featurep 'dbusbind)
+    (setq gnus-dbus-sleep-registration-object
+	  (dbus-register-signal :system
+				"org.freedesktop.login1"
+				"/org/freedesktop/login1"
+				"org.freedesktop.login1.Manager"
+				"PrepareForSleep"
+				#'gnus-dbus-sleep-handler))
+    (gnus-add-shutdown #'gnus-dbus-unregister-sleep-signal 'gnus)))
+
+(defun gnus-dbus-sleep-handler (sleep-start)
+  ;; Sleep-start is t before sleeping.
+  (when (and sleep-start
+	     (gnus-alive-p))
+    (condition-case nil
+	(gnus-close-all-servers)
+      (error nil))))
+
+(defun gnus-dbus-unregister-sleep-signal ()
+  (condition-case nil
+      (dbus-unregister-object
+       gnus-dbus-sleep-registration-object)
+    (wrong-type-argument nil)))
+
+(provide 'gnus-dbus)
+;;; gnus-dbus.el ends here
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index ba8b91be5c..fe600f107c 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -31,6 +31,7 @@
 (require 'gnus-range)
 (require 'gnus-util)
 (require 'gnus-cloud)
+(require 'gnus-dbus)
 (autoload 'message-make-date "message")
 (autoload 'gnus-agent-read-servers-validate "gnus-agent")
 (autoload 'gnus-agent-save-local "gnus-agent")
@@ -798,6 +799,8 @@ gnus-1
 	  (gnus-run-hooks 'gnus-setup-news-hook)
 	  (when gnus-agent
 	    (gnus-request-create-group "queue" '(nndraft "")))
+	  (when gnus-dbus-close-on-sleep
+	    (gnus-dbus-register-sleep-signal))
 	  (gnus-start-draft-setup)
 	  ;; Generate the group buffer.
 	  (gnus-group-list-groups level)
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index cecf4d4fb4..f615d49d27 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -292,6 +292,10 @@ gnus-fun
   :link '(custom-manual "(gnus)Exiting Gnus")
   :group 'gnus)
 
+(defgroup gnus-dbus nil
+  "D-Bus integration for Gnus."
+  :group 'gnus)
+
 (defconst gnus-version-number "5.13"
   "Version number for this version of Gnus.")
 
-- 
2.28.0


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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-21 20:43 bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration Eric Abrahamsen
@ 2020-08-22  6:33 ` Eli Zaretskii
  2020-08-22 13:53 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2020-08-22  6:33 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 42977

> From: Eric Abrahamsen <eric@ericabrahamsen.net>
> Date: Fri, 21 Aug 2020 13:43:07 -0700
> 
> I assume this would require a mention in the manual. Is it something
> we'd add to NEWS, as well?

Yes, IMO.

Thanks.





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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-21 20:43 bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration Eric Abrahamsen
  2020-08-22  6:33 ` Eli Zaretskii
@ 2020-08-22 13:53 ` Lars Ingebrigtsen
  2020-08-22 18:00   ` Eric Abrahamsen
  1 sibling, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-22 13:53 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 42977

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> The attached patch provides a new gnus-dbus.el library, allowing systems
> with dbus support to register a signal that closes all Gnus servers when
> the system is going down for sleep.

Great!  I've just skimmed the patch, but it looks good to me.

> I assume this would require a mention in the manual. Is it something
> we'd add to NEWS, as well?

Yup and yup.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-22 13:53 ` Lars Ingebrigtsen
@ 2020-08-22 18:00   ` Eric Abrahamsen
  2020-08-23 12:27     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Abrahamsen @ 2020-08-22 18:00 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 42977

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


On 08/22/20 15:53 PM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> The attached patch provides a new gnus-dbus.el library, allowing systems
>> with dbus support to register a signal that closes all Gnus servers when
>> the system is going down for sleep.
>
> Great!  I've just skimmed the patch, but it looks good to me.
>
>> I assume this would require a mention in the manual. Is it something
>> we'd add to NEWS, as well?
>
> Yup and yup.

Okay, good. Here's a new version of the patch, with docs. I also
switched the signal type from :system to :session, since :session is
apparently appropriate for user-level stuff. Anyway, I'll run this for a
few days before pushing.

Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-basic-D-Bus-integration-to-Gnus.patch --]
[-- Type: text/x-patch, Size: 7011 bytes --]

From 702961d4e8a1654cec7c3af26855899f65d62f10 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Fri, 21 Aug 2020 13:36:58 -0700
Subject: [PATCH 1/2] Add basic D-Bus integration to Gnus

* lisp/gnus/gnus-dbus.el: New library, registering a signal that
closes all Gnus servers when the system is going to sleep.
* lisp/gnus/gnus-start.el: Check new option
`gnus-dbus-close-on-sleep', and register the appropriate D-Bus signal
if it is non-nil.
* lisp/gnus/gnus.el: New gnus-dbus customization group.
* doc/misc/gnus.texi: Document.
---
 doc/misc/gnus.texi      | 22 +++++++++++++
 etc/NEWS                |  5 +++
 lisp/gnus/gnus-dbus.el  | 68 +++++++++++++++++++++++++++++++++++++++++
 lisp/gnus/gnus-start.el |  3 ++
 lisp/gnus/gnus.el       |  4 +++
 5 files changed, 102 insertions(+)
 create mode 100644 lisp/gnus/gnus-dbus.el

diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 332926a685..0bdc2fa297 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -828,6 +828,7 @@ Top
 * Spam Package::                A package for filtering and processing spam.
 * The Gnus Registry::           A package for tracking messages by Message-ID.
 * The Gnus Cloud::              A package for synchronizing Gnus marks.
+* D-Bus Integration::           Closing Gnus servers on system sleep.
 * Other modes::                 Interaction with other modes.
 * Various Various::             Things that are really various.
 
@@ -22333,6 +22334,7 @@ Various
 * Spam Package::                A package for filtering and processing spam.
 * The Gnus Registry::           A package for tracking messages by Message-ID.
 * The Gnus Cloud::              A package for synchronizing Gnus marks.
+* D-Bus Integration::           Closing Gnus servers on system sleep.
 * Other modes::                 Interaction with other modes.
 * Various Various::             Things that are really various.
 @end menu
@@ -26404,6 +26406,26 @@ Gnus Cloud Usage
 Server buffer (@pxref{Gnus Cloud Setup}).
 @end defvar
 
+@node D-Bus Integration
+@section D-Bus Integration
+@cindex dbus
+@cindex D-Bus
+@cindex gnus-dbus
+@cindex system sleep
+@cindex closing servers automatically
+@cindex hung connections
+
+When using laptops or other systems that have a sleep or hibernate
+functionality, it's possible for long-running server connections to
+become ``hung'', requiring the user to manually close and re-open the
+connections after the system resumes.  On systems compiled with D-Bus
+support (check the value of @code{(featurep 'dbusbind)}), Gnus can
+register a D-Bus signal to automatically close all server connections
+before the system goes to sleep.  To enable this, set
+@code{gnus-dbus-close-on-sleep} to a non-nil value.
+
+For more information about D-Bus and Emacs, @pxref{Top,,, dbus, D-Bus integration in Emacs}.
+
 @node Other modes
 @section Interaction with other modes
 
diff --git a/etc/NEWS b/etc/NEWS
index 0a6a7dec5c..5e7ad0073c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -267,6 +267,11 @@ tags to be considered as well.
 
 ** Gnus
 
++++
+*** New option 'gnus-dbus-close-on-sleep'
+On systems with D-Bus support, it is now possible to register a signal
+to close all Gnus servers before the system sleeps.
+
 +++
 *** The key binding of 'gnus-summary-search-article-forward' has changed.
 This command was previously on 'M-s' and shadowed the global 'M-s'
diff --git a/lisp/gnus/gnus-dbus.el b/lisp/gnus/gnus-dbus.el
new file mode 100644
index 0000000000..b6e8bb9c8b
--- /dev/null
+++ b/lisp/gnus/gnus-dbus.el
@@ -0,0 +1,68 @@
+;;; gnus-dbus.el --- DBUS integration for Gnus       -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020  Free Software Foundation, Inc.
+
+;; Author: Eric Abrahamsen <eric@ericabrahamsen.net>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library contains some Gnus integration for systems using DBUS.
+;; At present it registers a signal to close all Gnus servers before
+;; system sleep or hibernation.
+
+;;; Code:
+
+(require 'gnus)
+(require 'dbus)
+(declare-function gnus-close-all-servers "gnus-start")
+
+(defcustom gnus-dbus-close-on-sleep nil
+  "When non-nil, close Gnus servers on system sleep."
+  :group 'gnus-dbus
+  :type 'boolean)
+
+(defvar gnus-dbus-sleep-registration-object nil
+  "Object returned from `dbus-register-signal'.
+Used to unregister the signal.")
+
+(defun gnus-dbus-register-sleep-signal ()
+  "Use `dbus-register-signal' to close servers on sleep."
+  (when (featurep 'dbusbind)
+    (setq gnus-dbus-sleep-registration-object
+	  (dbus-register-signal :session
+				"org.freedesktop.login1"
+				"/org/freedesktop/login1"
+				"org.freedesktop.login1.Manager"
+				"PrepareForSleep"
+				#'gnus-dbus-sleep-handler))
+    (gnus-add-shutdown #'gnus-dbus-unregister-sleep-signal 'gnus)))
+
+(defun gnus-dbus-sleep-handler (sleep-start)
+  ;; Sleep-start is t before sleeping.
+  (when (and sleep-start
+	     (gnus-alive-p))
+    (condition-case nil
+	(gnus-close-all-servers)
+      (error nil))))
+
+(defun gnus-dbus-unregister-sleep-signal ()
+  (condition-case nil
+      (dbus-unregister-object
+       gnus-dbus-sleep-registration-object)
+    (wrong-type-argument nil)))
+
+(provide 'gnus-dbus)
+;;; gnus-dbus.el ends here
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index ba8b91be5c..fe600f107c 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -31,6 +31,7 @@
 (require 'gnus-range)
 (require 'gnus-util)
 (require 'gnus-cloud)
+(require 'gnus-dbus)
 (autoload 'message-make-date "message")
 (autoload 'gnus-agent-read-servers-validate "gnus-agent")
 (autoload 'gnus-agent-save-local "gnus-agent")
@@ -798,6 +799,8 @@ gnus-1
 	  (gnus-run-hooks 'gnus-setup-news-hook)
 	  (when gnus-agent
 	    (gnus-request-create-group "queue" '(nndraft "")))
+	  (when gnus-dbus-close-on-sleep
+	    (gnus-dbus-register-sleep-signal))
 	  (gnus-start-draft-setup)
 	  ;; Generate the group buffer.
 	  (gnus-group-list-groups level)
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index cecf4d4fb4..f615d49d27 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -292,6 +292,10 @@ gnus-fun
   :link '(custom-manual "(gnus)Exiting Gnus")
   :group 'gnus)
 
+(defgroup gnus-dbus nil
+  "D-Bus integration for Gnus."
+  :group 'gnus)
+
 (defconst gnus-version-number "5.13"
   "Version number for this version of Gnus.")
 
-- 
2.28.0


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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-22 18:00   ` Eric Abrahamsen
@ 2020-08-23 12:27     ` Lars Ingebrigtsen
  2020-08-25 17:43       ` Eric Abrahamsen
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-23 12:27 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 42977

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Okay, good. Here's a new version of the patch, with docs. I also
> switched the signal type from :system to :session, since :session is
> apparently appropriate for user-level stuff. Anyway, I'll run this for a
> few days before pushing.

Sounds good.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-23 12:27     ` Lars Ingebrigtsen
@ 2020-08-25 17:43       ` Eric Abrahamsen
  2020-08-25 19:21         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Abrahamsen @ 2020-08-25 17:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 42977


On 08/23/20 14:27 PM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Okay, good. Here's a new version of the patch, with docs. I also
>> switched the signal type from :system to :session, since :session is
>> apparently appropriate for user-level stuff. Anyway, I'll run this for a
>> few days before pushing.
>
> Sounds good.  :-)

Okay, there it goes. This was made a tiny bit more difficult to test by
the fact that the 'closed status (in `gnus-opened-servers') is set at
various calling sites, and not centrally in `gnus-close-server'.
`gnus-open-server' sets the 'open status, it seems like
`gnus-close-server' should do the equivalent. I could take it out of
`gnus-group-suspend', and look at whether `gnus-server-set-status' was
really necessary.

WDYT?

Eric





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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-25 17:43       ` Eric Abrahamsen
@ 2020-08-25 19:21         ` Lars Ingebrigtsen
  2020-08-25 19:33           ` Eric Abrahamsen
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-25 19:21 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 42977

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Okay, there it goes. This was made a tiny bit more difficult to test by
> the fact that the 'closed status (in `gnus-opened-servers') is set at
> various calling sites, and not centrally in `gnus-close-server'.
> `gnus-open-server' sets the 'open status, it seems like
> `gnus-close-server' should do the equivalent. I could take it out of
> `gnus-group-suspend', and look at whether `gnus-server-set-status' was
> really necessary.

I think the use case is stuff like this:

(defun gnus-agent-toggle-group-plugged (group)
  "Toggle the status of the server of the current group."
  (interactive (list (gnus-group-group-name)))
  (let* ((method (gnus-find-method-for-group group))
	 (status (cadr (assoc method gnus-opened-servers))))
    (if (eq status 'offline)
	(gnus-server-set-status method 'closed)
      (gnus-close-server method)
      (gnus-server-set-status method 'offline))

Where we close the server (i.e., the backends close the network
connections), but don't set the status to 'closed, because it's still
open on the Gnus side.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-25 19:21         ` Lars Ingebrigtsen
@ 2020-08-25 19:33           ` Eric Abrahamsen
  2020-08-25 19:37             ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Abrahamsen @ 2020-08-25 19:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 42977


On 08/25/20 21:21 PM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Okay, there it goes. This was made a tiny bit more difficult to test by
>> the fact that the 'closed status (in `gnus-opened-servers') is set at
>> various calling sites, and not centrally in `gnus-close-server'.
>> `gnus-open-server' sets the 'open status, it seems like
>> `gnus-close-server' should do the equivalent. I could take it out of
>> `gnus-group-suspend', and look at whether `gnus-server-set-status' was
>> really necessary.
>
> I think the use case is stuff like this:
>
> (defun gnus-agent-toggle-group-plugged (group)
>   "Toggle the status of the server of the current group."
>   (interactive (list (gnus-group-group-name)))
>   (let* ((method (gnus-find-method-for-group group))
> 	 (status (cadr (assoc method gnus-opened-servers))))
>     (if (eq status 'offline)
> 	(gnus-server-set-status method 'closed)
>       (gnus-close-server method)
>       (gnus-server-set-status method 'offline))
>
> Where we close the server (i.e., the backends close the network
> connections), but don't set the status to 'closed, because it's still
> open on the Gnus side.

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.

Alternately, we could just have `gnus-close-all-servers' set the status,
too.





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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-25 19:33           ` Eric Abrahamsen
@ 2020-08-25 19:37             ` Lars Ingebrigtsen
  2020-08-27  1:19               ` Eric Abrahamsen
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-25 19:37 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 42977

Eric Abrahamsen <eric@ericabrahamsen.net> 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.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-25 19:37             ` Lars Ingebrigtsen
@ 2020-08-27  1:19               ` Eric Abrahamsen
  2020-08-27 13:37                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Abrahamsen @ 2020-08-27  1:19 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 42977

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


On 08/25/20 21:37 PM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: close-gnus-servers.diff --]
[-- Type: text/x-patch, Size: 1446 bytes --]

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."

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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-27  1:19               ` Eric Abrahamsen
@ 2020-08-27 13:37                 ` Lars Ingebrigtsen
  2020-08-27 21:20                   ` Eric Abrahamsen
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-27 13:37 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 42977

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

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

Looks good to me.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration
  2020-08-27 13:37                 ` Lars Ingebrigtsen
@ 2020-08-27 21:20                   ` Eric Abrahamsen
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Abrahamsen @ 2020-08-27 21:20 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 42977, 42977-done

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> 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.
>
> Looks good to me.

Cool, in it goes. It turns out the signal needed to be :system after
all, not :session, so I made that change as well, and am closing this
report.

Thanks,
Eric





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

end of thread, other threads:[~2020-08-27 21:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 20:43 bug#42977: 28.0.50; New gnus-dbus library providing (optional) D-Bus->Gnus integration Eric Abrahamsen
2020-08-22  6:33 ` Eli Zaretskii
2020-08-22 13:53 ` Lars Ingebrigtsen
2020-08-22 18:00   ` Eric Abrahamsen
2020-08-23 12:27     ` Lars Ingebrigtsen
2020-08-25 17:43       ` Eric Abrahamsen
2020-08-25 19:21         ` Lars Ingebrigtsen
2020-08-25 19:33           ` Eric Abrahamsen
2020-08-25 19:37             ` Lars Ingebrigtsen
2020-08-27  1:19               ` Eric Abrahamsen
2020-08-27 13:37                 ` Lars Ingebrigtsen
2020-08-27 21:20                   ` Eric Abrahamsen

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).