Subject: [PATCH] nnfeed: (Mostly) fix group descriptions

From: Daniel Semyonov <[email-masked]>
Date: Tue, 02 Jul 2024 02:43:29 +0300

Tags: patch

Hi,

I realized a few days ago I barely tested group descriptions in nnatom
(and by extension nnfeed), and turns out they were in fact broken.
Attached is a patch which should fix them.

Also, while working on this patch I found out the Gnus backend interface
docs are slightly misleading on this subject - Gnus reads a group
description per line inserted in the " *nntpd*" buffer, with each line
containing a group's name followed by its description.
Contrary to the docs, the separator between the name and its associated
description is either a space or a tab (the docs only mention a tab).
This is why this is "mostly" fixed, as groups with a space in their name
will incorrectly include any part of the name after the first space in
the description.

I don't currently have time to go over all other backends to see if
changing this to reflect the docs will break anything, so I just added a
comment about it.

Daniel

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.41, cairo version 1.18.0) of 2024-06-12 built on coldharbour
Repository revision: 3905db6e3aa947b847c072259ad6d08c8a15e10e
Repository branch: master
System Description: Void Linux

Configured using:
 'configure -C --prefix=/opt/Emacs --without-x --with-pgtk
 --with-small-ja-dic --with-native-compilation 'CFLAGS=-march=native
 -O2''

>From b7cbb2d58cab74eb6137ad05d64466b249cbadf4 Mon Sep 17 00:00:00 2001
From: Daniel Semyonov <[email-masked]>
Date: Tue, 2 Jul 2024 01:42:26 +0300
Subject: [PATCH] nnfeed: (Mostly) fix group descriptions

* lisp/gnus/nnfeed.el (nnfeed--group-description): New function.
(nnfeed-request-group-description)
(nnfeed-request-list-newsgroups): Use
`nnfeed--group-description' and always return t if group data is
found.
---
 lisp/gnus/nnfeed.el | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lisp/gnus/nnfeed.el b/lisp/gnus/nnfeed.el
index d6963b2e929..2d33d4c813b 100644
--- a/lisp/gnus/nnfeed.el
+++ b/lisp/gnus/nnfeed.el
@@ -630,12 +630,21 @@ nnfeed-retrieve-groups
 (deffoo nnfeed-request-type (_group &optional _article)
   'unknown)
 
+;; FIXME: Works incorrectly when a group name contains spaces as Gnus actually
+;; separates the group name from the description with either a tab or a space.
+(defun nnfeed--group-description (name group)
+  "Return a description line for a GROUP called NAME."
+  (when-let ((desc (aref group 5))
+             ((not (string-blank-p desc))))
+    (insert name "\t" desc "\n")))
+
 (deffoo nnfeed-request-group-description (group &optional server)
   (when-let ((server (or server (nnfeed--current-server-no-prefix)))
              (g (nnfeed--group-data group server)))
     (with-current-buffer nntp-server-buffer
       (erase-buffer)
-      (insert group "	" (aref g 5) "\n"))))
+      (nnfeed--group-description group g)
+      t)))
 
 (deffoo nnfeed-request-list-newsgroups (&optional server)
   (when-let ((server (or server (nnfeed--current-server-no-prefix)))
@@ -643,9 +652,8 @@ nnfeed-request-list-newsgroups
              ((hash-table-p s)))
     (with-current-buffer nntp-server-buffer
       (erase-buffer)
-      (maphash (lambda (group g)
-                 (insert group "	" (aref g 5) "\n"))
-               s))))
+      (maphash #'nnfeed--group-description s)
+      t)))
 
 (deffoo nnfeed-request-rename-group (group new-name &optional server)
   (when-let ((server (or server (nnfeed--current-server-no-prefix)))
-- 
2.45.2