Re: nntp and nnimap disconnect and take forever when emacs is idle

Stephen Berman <[email protected]> Tue, 22 Oct 2024 09:57:59 +0200
Newsgroups gmane.emacs.gnus.general
Message-ID <[email protected]>
On Tue, 22 Oct 2024 04:59:04 +0000 Divya Ranjan <[email protected]> wrote:

> Does anyone else also experience this, when they’ve left their Emacs or just
> gnus idle for sometime, it disconnects from the server, whether nntp or
> nnimap, and then when you open a group that’s requesting that server, it takes
> forever to load. Is this one of those things that you have to swallow with
> Gnus, or is there some hack?

At least concerning nntp this sounds like bug#52735 (which I continue to
experience); see also the thread beginning at
<https://lists.gnu.org/archive/html/info-gnus-english/2023-06/msg00014.html>.

I use the following hack, added to my ~/.emacs.d/.gnus.el file:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun srb-gnus-group-get-new-news (&optional arg one-level)
  (interactive "P")
  (with-timeout (1 (kill-buffer (nntp-find-connection-buffer
                                 nntp-server-buffer))
		   (gnus-group-get-new-news))
    (gnus-group-get-new-news arg one-level)))

(defun srb-gnus-summary-next-unread-article ()
  (interactive)
  (with-timeout (1 (kill-buffer (nntp-find-connection-buffer
                                 nntp-server-buffer))
		   (gnus-summary-next-unread-article))
    (gnus-summary-next-unread-article)))

(defun srb-gnus-summary-next-page (&optional lines circular stop)
  (interactive "P")
  (with-timeout (1 (kill-buffer (nntp-find-connection-buffer
                                 nntp-server-buffer))
		   (gnus-summary-next-page))
    (gnus-summary-next-page lines circular stop)))

(defun srb-gnus-summary-scroll-up (lines)
  (interactive "P")
  (with-timeout (1 (kill-buffer (nntp-find-connection-buffer
                                 nntp-server-buffer))
		   (gnus-summary-scroll-up lines))
    (gnus-summary-scroll-up lines)))

(define-key gnus-group-mode-map "g" 'srb-gnus-group-get-new-news)
(define-key gnus-summary-mode-map "n" 'srb-gnus-summary-next-unread-article)
(define-key gnus-summary-mode-map " " 'srb-gnus-summary-next-page)
(define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

But this is brittle and doesn't always work.  If you find a real
solution, I'd be interested to see it.

Steve Berman