Subject: bug#44981: 28.0.50; Restore nnimap-split-download-body?

From: Eric Abrahamsen <[email-masked]>
Date: Mon, 30 Nov 2020 20:12:13 -0800

When splitting IMAP messages in Gnus' nnimap, there is a defvar called
`nnimap-split-download-body-default', which is consulted to decide
whether to download the whole message body during splitting, or only
consider its headers.

It appears that there used to be a defcustom called
`nnimap-split-download-body', which was advertised to the user, and this
defvar was used to hold... its default? It's odd.

In 2010, in commit 20a673b2d, a bunch of external Gnus code was merged
in, changing a lot of nnimap.el, and in the course of that the defcustom
was deleted. The defvar still remains, and is still effective. The
manual still refers to the customization option.

This looks unintentional, and I'd like to apply the attached diff,
restoring `nnimap-split-download-body' as a user option, and getting rid
of the default variable, which seems unnecessary. If this seems okay
I'll do up a proper commit, and make sure the documentation is all
accurate.

The same user who reported this also expressed a desire to be able to
download message bodies conditionally, based on the headers, only if
a split rule required it. I'm not at all sure about the feasibility of
that, but wanted to see if anyone else had an opinion.

Eric

diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 7984998d21..1a1e13a23a 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -146,13 +146,16 @@ nnimap-request-articles-find-limit
   :version "24.4"
   :group 'nnimap)
 
+(defcustom nnimap-split-download-body nil
+  "If non-nil, splitting may also consider message bodies.
+This requires downloading the full message from the IMAP server
+during splitting, which may be slow."
+  :type 'boolean)
+
 (defvar nnimap-process nil)
 
 (defvar nnimap-status-string "")
 
-(defvar nnimap-split-download-body-default nil
-  "Internal variable with default value for `nnimap-split-download-body'.")
-
 (defvar nnimap-keepalive-timer nil)
 (defvar nnimap-process-buffers nil)
 
@@ -2100,7 +2103,7 @@ nnimap-fetch-inbox
 		 "BODY.PEEK"
 	       "RFC822.PEEK"))
 	    (cond
-	     (nnimap-split-download-body-default
+	     (nnimap-split-download-body
 	      "[]")
 	     ((nnimap-ver4-p)
 	      "[HEADER]")