💾 Archived View for perplexing.space › 2021 › nntp-in-emacs.gmi captured on 2023-09-08 at 15:55:43. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

NNTP in Emacs

2021-03-05

The tildeverse has their own usenet! Most people seem to use slrn or tin but for much the same reason I use elpher for gopher and gemini, I don't want to learn another program and run it in another shell. The solution is obviously to configure emacs for my news reading!

The most obvious contender is gnus, which has the advantage of coming bundled with emacs.

Gnus

To get stared browsing it seems sufficient to do the following:

(setq gnus-select-method '(nntp "news.tilde.club"))

From there you might M-x gnus and browse available groups with "U U" -- this is about where I stopped though. I have a few qualms with the default gnus interface that I decided to try wanderlust instead of diving into configuration.

Wanderlust

Wanderlust File

Wanderlust specific configuration goes in a file: ~/.wl

For mine, I only really care to hide some of the headers that are especially verbose in regular mail. It is less noisy in NNTP messages but I don't need to see them all the time:

(setq wl-message-ignored-field-list '("^.*:")
      wl-message-visible-field-list '("^To:"
                                      "^Cc:"
                                      "^From:"
                                      "^Subject:"
                                      "^Date:")) 

Subscriptions

I don't really know which groups are the most active or interesting, so let's subscribe to most of them for now. The following goes in a file: ~/.folders

The first is for my maildir on tilde.club and actually points to the value of the variable elmo-maildir-file-path (for me that is ~/.mail):

.
-local.test@news.tilde.club
-tilde.club@news.tilde.club
-tilde.cosmic@news.tilde.club
-tilde.food+drink@news.tilde.club
-tilde.gopher@news.tilde.club
-tilde.meta@news.tilde.club
-tilde.projects@news.tilde.club
-tilde.services@news.tilde.club
-tilde.text@news.tilde.club
-tilde.your@news.tilde.club

All of this is a little more involved than mail in emacs on SDF, where the more classic single-file mail means M-x rmail "just works" - but it isn't too much. Gnus continues to befuddle me, but wanderlust is nice enough and the included info pages are well written. I'm sure there's more I could do with it like scoring, refiling, or archiving but for now as slow as things are I don't need to worry about it.

One thing I should eventually figure out is a message in the minibuffer upon retrieving news messages:

Blocking call to accept-process-output with quit inhibited!!

I half-suspect it is a result of the particular NNTP server running on news.tilde.club because of the format in the process output buffer. There doesn't appear to be any effect negative or otherwise so it is low priority for me.

Go check it out!

Addendum

I received an e-mail from Chris which helps explain the "quit prohibited" message:

A 'blocking call' means that the code is entering a block of code where it will no longer listen for user input, meaning you can't do anything while Emacs finishes processing that call. The 'quit-prohibited' part means that the author of that code has marked that code as not being interruptible by the user, i.e. via C-g, hopefully because it's doing something sensitive that could break something if it's interrupted. Together this means that the code producing that message is making your Emacs session non-responsive in a way that you can't break out of (short of killing emacs) which is why the warning message pops up. If that code were to hit an infinite loop or wait for a network or file I/O call that never timed out, your Emacs would hang indefinitely.
That being said, I don't know if there's much you could do about it, short of trying to rewrite the code that enters that state so it doesn't need to block or is otherwise safe to quit from.

Thank you! With this new lead I managed to track things down and found that when Wanderlust was written over 20 years ago; calls to accept-process-output were not flagged by Emacs as potentially problematic if the process became hung up; This feature was added about 10 years ago (2b0a91e78f83fb446cc38efb99399e83ad2cded3) with the explanation that Emacs would now:

Output a warning when called in such a way that it could block without being interruptible.

So best practices have shifted a bit in the intervening decades! The solution is to patch Wanderlust, specifically elmo-nntp-read-body and elmo-nntp-read-response — this is covered in the manual if you know where to look:

If a timer function needs to allow quitting, it should use with-local-quit (see Quitting). For example, if a timer function calls accept-process-output to receive output from an external process, that call should be wrapped inside with-local-quit, to ensure that C-g works if the external process hangs.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Timers.html

The full patch then is this:

--- elmo-nntp.el	2021-02-26 10:11:46.906783322 -0500
+++ elmo-nntp.el	2021-03-05 13:20:54.728571637 -0500
@@ -355,7 +355,7 @@
 	(while (null (progn (goto-char match-end)
 			    (search-forward "\r\n" nil t)))
 	  (setq match-end (max (1- (point-max)) elmo-nntp-read-point))
-	  (accept-process-output process))
+	  (with-local-quit (accept-process-output process)))
 	(setq match-end (point)
 	      last elmo-nntp-read-point
 	      elmo-nntp-read-point match-end)
@@ -401,8 +401,8 @@
       (while (null (progn (goto-char (1- point))
 			  (search-forward "\n.\r\n" nil t)))
 	(setq point (max (- (point-max) 2) elmo-nntp-read-point))
-	(accept-process-output
-	 (elmo-network-session-process-internal session)))
+	(with-local-quit (accept-process-output
+	 (elmo-network-session-process-internal session))))
       (setq point (point))
       (set-buffer outbuf)
       (erase-buffer)