diff options
| author | Basil L. Contovounesios | 2020-12-05 15:28:35 +0000 |
|---|---|---|
| committer | Basil L. Contovounesios | 2020-12-06 11:45:52 +0000 |
| commit | e84a1ffde9047c1ca0acb9abcd6d31e3bfba457d (patch) | |
| tree | 25d5b83111ce74d46e87875d3a3659488e47afe7 | |
| parent | 61497defb42e84a7ca32774a0ac16b30789f91d8 (diff) | |
| download | emacs-e84a1ffde9047c1ca0acb9abcd6d31e3bfba457d.tar.gz emacs-e84a1ffde9047c1ca0acb9abcd6d31e3bfba457d.zip | |
Avoid modifying nnimap user option 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 user option
nnimap-split-download-body, set nnimap--split-download-body to a
unique non-nil value only if the variable was nil (bug#44981).
(spam-teardown-widening): New function that undoes this if
nnimap--split-download-body still holds the unique value.
(spam-unload-hook): Call spam-teardown-widening to revert any change
to the value of nnimap--split-download-body.
| -rw-r--r-- | lisp/gnus/nnimap.el | 6 | ||||
| -rw-r--r-- | 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 a8603330662..c8b700ebcc6 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el | |||
| @@ -157,6 +157,9 @@ during splitting, which may be slow." | |||
| 157 | :version "28.1" | 157 | :version "28.1" |
| 158 | :type 'boolean) | 158 | :type 'boolean) |
| 159 | 159 | ||
| 160 | (defvar nnimap--split-download-body nil | ||
| 161 | "Like `nnimap-split-download-body', but for internal use.") | ||
| 162 | |||
| 160 | (defvar nnimap-process nil) | 163 | (defvar nnimap-process nil) |
| 161 | 164 | ||
| 162 | (defvar nnimap-status-string "") | 165 | (defvar nnimap-status-string "") |
| @@ -2108,7 +2111,8 @@ Return the server's response to the SELECT or EXAMINE command." | |||
| 2108 | "BODY.PEEK" | 2111 | "BODY.PEEK" |
| 2109 | "RFC822.PEEK")) | 2112 | "RFC822.PEEK")) |
| 2110 | (cond | 2113 | (cond |
| 2111 | (nnimap-split-download-body | 2114 | ((or nnimap-split-download-body |
| 2115 | nnimap--split-download-body) | ||
| 2112 | "[]") | 2116 | "[]") |
| 2113 | ((nnimap-ver4-p) | 2117 | ((nnimap-ver4-p) |
| 2114 | "[HEADER]") | 2118 | "[HEADER]") |
diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el index 27e559d383a..e74aef3efe6 100644 --- a/lisp/gnus/spam.el +++ b/lisp/gnus/spam.el | |||
| @@ -44,12 +44,9 @@ | |||
| 44 | ;;; for the definitions of group content classification and spam processors | 44 | ;;; for the definitions of group content classification and spam processors |
| 45 | (require 'gnus) | 45 | (require 'gnus) |
| 46 | 46 | ||
| 47 | (eval-when-compile (require 'hashcash)) | 47 | (eval-when-compile |
| 48 | 48 | (require 'cl-lib) | |
| 49 | ;; for nnimap-split-download-body | 49 | (require 'hashcash)) |
| 50 | (eval-when-compile (require 'nnimap)) | ||
| 51 | |||
| 52 | (eval-when-compile (require 'cl-lib)) | ||
| 53 | 50 | ||
| 54 | ;; autoload query-dig | 51 | ;; autoload query-dig |
| 55 | (autoload 'query-dig "dig") | 52 | (autoload 'query-dig "dig") |
| @@ -1228,10 +1225,20 @@ Will not return a nil score." | |||
| 1228 | 1225 | ||
| 1229 | ;;{{{ set up widening, processor checks | 1226 | ;;{{{ set up widening, processor checks |
| 1230 | 1227 | ||
| 1231 | ;;; set up IMAP widening if it's necessary | 1228 | (defconst spam--widened (list ()) |
| 1229 | "Unique value identifying changes to `nnimap--split-download-body'.") | ||
| 1230 | |||
| 1232 | (defun spam-setup-widening () | 1231 | (defun spam-setup-widening () |
| 1233 | (when (spam-widening-needed-p) | 1232 | "Set up IMAP widening if it's necessary." |
| 1234 | (setq nnimap-split-download-body t))) | 1233 | (and (boundp 'nnimap--split-download-body) |
| 1234 | (not nnimap--split-download-body) | ||
| 1235 | (spam-widening-needed-p) | ||
| 1236 | (setq nnimap--split-download-body spam--widened))) | ||
| 1237 | |||
| 1238 | (defun spam-teardown-widening () | ||
| 1239 | "Tear down IMAP widening." | ||
| 1240 | (when (eq (bound-and-true-p nnimap--split-download-body) spam--widened) | ||
| 1241 | (setq nnimap--split-download-body nil))) | ||
| 1235 | 1242 | ||
| 1236 | (defun spam-widening-needed-p (&optional force-symbols) | 1243 | (defun spam-widening-needed-p (&optional force-symbols) |
| 1237 | (let (found) | 1244 | (let (found) |
| @@ -2865,6 +2872,7 @@ installed through `spam-necessary-extra-headers'." | |||
| 2865 | (defun spam-unload-hook () | 2872 | (defun spam-unload-hook () |
| 2866 | "Uninstall the spam.el hooks." | 2873 | "Uninstall the spam.el hooks." |
| 2867 | (interactive) | 2874 | (interactive) |
| 2875 | (spam-teardown-widening) | ||
| 2868 | (remove-hook 'gnus-save-newsrc-hook 'spam-maybe-spam-stat-save) | 2876 | (remove-hook 'gnus-save-newsrc-hook 'spam-maybe-spam-stat-save) |
| 2869 | (remove-hook 'gnus-get-top-new-news-hook 'spam-maybe-spam-stat-load) | 2877 | (remove-hook 'gnus-get-top-new-news-hook 'spam-maybe-spam-stat-load) |
| 2870 | (remove-hook 'gnus-startup-hook 'spam-maybe-spam-stat-load) | 2878 | (remove-hook 'gnus-startup-hook 'spam-maybe-spam-stat-load) |