From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 44981@debbugs.gnu.org
Subject: bug#44981: 28.0.50; Restore nnimap-split-download-body?
Date: Sat, 05 Dec 2020 15:57:17 +0000 [thread overview]
Message-ID: <87wnxw1c0y.fsf@tcd.ie> (raw)
In-Reply-To: <87pn3pmn4i.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Fri, 04 Dec 2020 10:39:41 -0800")
[-- Attachment #1: Type: text/plain, Size: 757 bytes --]
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> I'm not sure why spam.el would need to work on the default value of
> `nnimap-split-download-body'. If spam.el determines that widening is
> needed, it's going to download message bodies across the board anyway.
> The only reason to preserve the user's own customization would be if the
> user later unloaded spam.el -- then it should restore the previous
> value. But how often would that actually be useful?
>
> In principle, TRT would be to have spam.el let-bind a variable around
> the splitting process. But I don't think the code is set up that way:
> all the spam.el stuff happens "inside" the splitting process, not around
> it.
How about the attached kludgy but conservative dance?
--
Basil
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Stop-using-deprecated-nnimap-variable-in-spam.el.patch --]
[-- Type: text/x-diff, Size: 3427 bytes --]
From 9792b97faf4e5b1dc22e58d99806ec17a9fd7985 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sat, 5 Dec 2020 15:28:35 +0000
Subject: [PATCH] Stop using deprecated nnimap variable in spam.el
* lisp/gnus/nnimap.el (nnimap--split-download-body): New variable.
(nnimap-fetch-inbox): Use it in conjunction with
nnimap-split-download-body.
* lisp/gnus/spam.el: Don't load nnimap.el at compile time for a
dynamic variable.
(spam-setup-widening): Rather than unconditionally set deprecated
nnimap-split-download-body-default, set nnimap--split-download-body
to recognizable non-nil value only if it is nil (bug#44981).
(spam-teardown-widening): Undo this if nnimap--split-download-body
still holds the recognizable value.
(spam-unload-hook): Call spam-teardown-widening to revert any change
to the value of nnimap--split-download-body.
---
lisp/gnus/nnimap.el | 6 +++++-
lisp/gnus/spam.el | 26 +++++++++++++++++---------
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index a860333066..c8b700ebcc 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -157,6 +157,9 @@ nnimap-split-download-body
:version "28.1"
:type 'boolean)
+(defvar nnimap--split-download-body nil
+ "Like `nnimap-split-download-body', but for internal use.")
+
(defvar nnimap-process nil)
(defvar nnimap-status-string "")
@@ -2108,7 +2111,8 @@ nnimap-fetch-inbox
"BODY.PEEK"
"RFC822.PEEK"))
(cond
- (nnimap-split-download-body
+ ((or nnimap-split-download-body
+ nnimap--split-download-body)
"[]")
((nnimap-ver4-p)
"[HEADER]")
diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el
index 96a7da2313..e74aef3efe 100644
--- a/lisp/gnus/spam.el
+++ b/lisp/gnus/spam.el
@@ -44,12 +44,9 @@
;;; for the definitions of group content classification and spam processors
(require 'gnus)
-(eval-when-compile (require 'hashcash))
-
-;; for nnimap-split-download-body-default
-(eval-when-compile (require 'nnimap))
-
-(eval-when-compile (require 'cl-lib))
+(eval-when-compile
+ (require 'cl-lib)
+ (require 'hashcash))
;; autoload query-dig
(autoload 'query-dig "dig")
@@ -1228,10 +1225,20 @@ spam-generic-score
;;{{{ set up widening, processor checks
-;;; set up IMAP widening if it's necessary
+(defconst spam--widened (list ())
+ "Unique value identifying changes to `nnimap--split-download-body'.")
+
(defun spam-setup-widening ()
- (when (spam-widening-needed-p)
- (setq nnimap-split-download-body-default t)))
+ "Set up IMAP widening if it's necessary."
+ (and (boundp 'nnimap--split-download-body)
+ (not nnimap--split-download-body)
+ (spam-widening-needed-p)
+ (setq nnimap--split-download-body spam--widened)))
+
+(defun spam-teardown-widening ()
+ "Tear down IMAP widening."
+ (when (eq (bound-and-true-p nnimap--split-download-body) spam--widened)
+ (setq nnimap--split-download-body nil)))
(defun spam-widening-needed-p (&optional force-symbols)
(let (found)
@@ -2865,6 +2872,7 @@ spam-initialize
(defun spam-unload-hook ()
"Uninstall the spam.el hooks."
(interactive)
+ (spam-teardown-widening)
(remove-hook 'gnus-save-newsrc-hook 'spam-maybe-spam-stat-save)
(remove-hook 'gnus-get-top-new-news-hook 'spam-maybe-spam-stat-load)
(remove-hook 'gnus-startup-hook 'spam-maybe-spam-stat-load)
--
2.29.2
next prev parent reply other threads:[~2020-12-05 15:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 4:12 bug#44981: 28.0.50; Restore nnimap-split-download-body? Eric Abrahamsen
2020-12-02 10:28 ` Lars Ingebrigtsen
2020-12-02 21:01 ` Basil L. Contovounesios
2020-12-02 21:18 ` Eric Abrahamsen
2020-12-03 8:03 ` Lars Ingebrigtsen
2020-12-02 23:56 ` Eric Abrahamsen
2020-12-03 8:10 ` Lars Ingebrigtsen
2020-12-03 18:20 ` Eric Abrahamsen
2020-12-04 10:45 ` Basil L. Contovounesios
2020-12-04 18:39 ` Eric Abrahamsen
2020-12-05 15:57 ` Basil L. Contovounesios [this message]
2020-12-05 19:48 ` Eric Abrahamsen
2020-12-06 12:06 ` Basil L. Contovounesios
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wnxw1c0y.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=44981@debbugs.gnu.org \
--cc=eric@ericabrahamsen.net \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.