summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorgan Smith <Morgan.J.Smith@outlook.com>2026-01-20 15:18:33 -0500
committerMichael Albinus <michael.albinus@gmx.de>2026-05-09 12:50:04 +0200
commit984024daf3cea96d760c9d6a3a89d826a0750fb6 (patch)
treea4193a5fff2372f1fd064f8b30bc00fe690f9126
parentd7c130972e08875c97731ceeb31e198696659b05 (diff)
Gnus: Use new sleep library
* etc/NEWS: Announce. * lisp/gnus/gnus-start.el: Don't require gnus-dbus. (gnus-sleep-handler): New function. (gnus-close-on-sleep): New variable. (gnus-1): Add `gnus-sleep-handler' to `system-sleep-event-functions' when `gnus-close-on-sleep' is non-nil. * doc/misc/gnus.texi: Update documentation.
-rw-r--r--doc/misc/gnus.texi25
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/gnus/gnus-start.el22
3 files changed, 38 insertions, 17 deletions
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index a440aac1a90..fffe81eac06 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -849,7 +849,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.
+* System Sleep Integration:: Closing Gnus servers on system sleep.
* Other modes:: Interaction with other modes.
* Various Various:: Things that are really various.
@@ -22712,7 +22712,7 @@ For instance, @code{nnir-notmuch-program} is now
* 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.
+* System Sleep Integration:: Closing Gnus servers on system sleep.
* Other modes:: Interaction with other modes.
* Various Various:: Things that are really various.
@end menu
@@ -26680,11 +26680,11 @@ CloudSynchronizationDataPack(TM)s. It's easiest to set this from the
Server buffer (@pxref{Gnus Cloud Setup}).
@end defvar
-@node D-Bus Integration
-@section D-Bus Integration
-@cindex dbus
-@cindex D-Bus
-@cindex gnus-dbus
+@node System Sleep Integration
+@section System Sleep Integration
+@c Section name changed from this in Emacs 31. @c
+@c This anchor allows old links to continue working. @c
+@anchor{D-Bus Integration}
@cindex system sleep
@cindex closing servers automatically
@cindex hung connections
@@ -26692,13 +26692,10 @@ Server buffer (@pxref{Gnus Cloud Setup}).
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-@code{nil} value.
-
-For more information about D-Bus and Emacs, @pxref{Top,,, dbus, D-Bus integration in Emacs}.
+connections after the system resumes. Using the system sleep library,
+Gnus can automatically close all server connections before the system
+goes to sleep. To enable this, set @code{gnus-close-on-sleep} to a
+non-@code{nil} value.
@node Other modes
@section Interaction with other modes
diff --git a/etc/NEWS b/etc/NEWS
index 0c221d049e0..1fe24bd61e4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1967,6 +1967,14 @@ Gnus, see "(gnus) Symbolic Prefixes" in the Gnus manual.
---
*** Sorting selected groups is now possible with 'gnus-topic-mode'.
++++
+*** System sleep integration is now independent of D-Bus.
+The system sleep integration previously provided by customizing the
+variable 'gnus-dbus-close-on-sleep' is now deprecated. A new system
+using the builtin sleep library is now available by customizing
+'gnus-close-on-sleep'. This will work on all systems that the sleep
+library supports.
+
** Sieve
+++
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index f63fc41ea5e..ba308990407 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -31,7 +31,6 @@
(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")
@@ -733,6 +732,22 @@ the first newsgroup."
;; Remove Gnus frames.
(gnus-kill-gnus-frames))
+(defcustom gnus-close-on-sleep nil
+ "When non-nil, close Gnus servers on system sleep."
+ :type 'boolean
+ :group 'gnus-start)
+
+(defun gnus-sleep-handler (sleep-event)
+ "Close connection to servers before system sleep.
+See `gnus-close-on-sleep' to enable this functionality.
+
+SLEEP-EVENT is checked to ensure this is only run before sleep."
+ (when (and (eq 'pre-sleep (sleep-event-state sleep-event))
+ (gnus-alive-p))
+ (condition-case nil
+ (gnus-close-all-servers)
+ (error nil))))
+
(defun gnus-no-server-1 (&optional arg child)
"Read network news.
If ARG is a positive number, Gnus will use that as the startup
@@ -800,8 +815,9 @@ prompt the user for the name of an NNTP server to use."
(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))
+ (when gnus-close-on-sleep
+ (add-hook 'system-sleep-event-functions
+ #'gnus-sleep-handler))
(gnus-start-draft-setup)
;; Generate the group buffer.
(gnus-group-list-groups level)