diff options
| author | Nikolaus Rath | 2019-09-27 01:39:13 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-09-27 01:39:13 +0200 |
| commit | fd6f4bf648c5a4417eb591a8c54b87c7c60de154 (patch) | |
| tree | f126bf32ae1ba6dc076219af7290976458d08ebc | |
| parent | ff8a72fbe0f6e168e2871a53bbdaded4d0cc5612 (diff) | |
| download | emacs-fd6f4bf648c5a4417eb591a8c54b87c7c60de154.tar.gz emacs-fd6f4bf648c5a4417eb591a8c54b87c7c60de154.zip | |
nnimap.el: support additional expunge options
* lisp/gnus/nnimap.el (nnimap-close-group)
(nnimap-request-expire-articles, nnimap-delete-article)
(nnimap-request-scan): Add new 'never, 'immediate, and 'on-exit
settings for nnimap-expunge (bug#20670).
| -rw-r--r-- | doc/misc/gnus.texi | 16 | ||||
| -rw-r--r-- | etc/NEWS | 10 | ||||
| -rw-r--r-- | lisp/gnus/nnimap.el | 80 |
3 files changed, 67 insertions, 39 deletions
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index d8a257b00bf..15b108541ce 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi | |||
| @@ -14305,9 +14305,19 @@ specific login method to be used, you can set this variable to either | |||
| 14305 | @code{plain} or @code{cram-md5}. | 14305 | @code{plain} or @code{cram-md5}. |
| 14306 | 14306 | ||
| 14307 | @item nnimap-expunge | 14307 | @item nnimap-expunge |
| 14308 | If non-@code{nil}, expunge articles after deleting them. This is always done | 14308 | When to expunge deleted messages. If @code{never}, deleted articles |
| 14309 | if the server supports UID EXPUNGE, but it's not done by default on | 14309 | are marked with the IMAP @code{\\Delete} flag but not automatically |
| 14310 | servers that doesn't support that command. | 14310 | expunged. If @code{immediately}, deleted articles are immediately expunged |
| 14311 | (this requires the server to support the UID EXPUNGE command). If | ||
| 14312 | @code{on-exit}, deleted articles are flagged, and all flagged articles are | ||
| 14313 | expunged when the group is closed. | ||
| 14314 | |||
| 14315 | For backwards compatibility, this variable may also be set to t | ||
| 14316 | or nil. If the server supports UID EXPUNGE, both t and nil are | ||
| 14317 | equivalent to @code{immediately}. If the server does not support UID | ||
| 14318 | EXPUNGE nil is equivalent to @code{never}, while t will immediately | ||
| 14319 | expunge ALL articles that are currently flagged as deleted | ||
| 14320 | (i.e., potentially not only the article that was just deleted). | ||
| 14311 | 14321 | ||
| 14312 | @item nnimap-streaming | 14322 | @item nnimap-streaming |
| 14313 | Virtually all @acronym{IMAP} server support fast streaming of data. | 14323 | Virtually all @acronym{IMAP} server support fast streaming of data. |
| @@ -1044,6 +1044,16 @@ Of course it will still find it if you have it in '~/.ecompleterc'. | |||
| 1044 | ** Gnus | 1044 | ** Gnus |
| 1045 | 1045 | ||
| 1046 | +++ | 1046 | +++ |
| 1047 | ** The Gnus user variable 'nnimap-expunge' supports three new values: | ||
| 1048 | 'never' for never expunging messages, 'immediately' for immediately | ||
| 1049 | expunging deleted messages, and 'on-exit' to expunge deleted articles | ||
| 1050 | when exiting the group's summary buffer. Setting 'nnimap-expunge' to | ||
| 1051 | 'nil' or 't' is still supported but not recommended, since it may | ||
| 1052 | result in Gnus expunging all messages that have been flagged as | ||
| 1053 | deleted by any IMAP client (rather than just those that have been | ||
| 1054 | deleted by Gnus). | ||
| 1055 | |||
| 1056 | +++ | ||
| 1047 | *** New option 'gnus-use-atomic-windows' makes Gnus window layouts | 1057 | *** New option 'gnus-use-atomic-windows' makes Gnus window layouts |
| 1048 | atomic. See the "Atomic Windows" section of the Elisp manual for | 1058 | atomic. See the "Atomic Windows" section of the Elisp manual for |
| 1049 | details. | 1059 | details. |
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 363e4186cbc..345667b927b 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el | |||
| @@ -102,10 +102,21 @@ Uses the same syntax as `nnmail-split-methods'.") | |||
| 102 | Possible choices are nil (use default methods), `anonymous', | 102 | Possible choices are nil (use default methods), `anonymous', |
| 103 | `login', `plain' and `cram-md5'.") | 103 | `login', `plain' and `cram-md5'.") |
| 104 | 104 | ||
| 105 | (defvoo nnimap-expunge t | 105 | (defvoo nnimap-expunge 'on-exit |
| 106 | "If non-nil, expunge articles after deleting them. | 106 | "When to expunge deleted messages. |
| 107 | This is always done if the server supports UID EXPUNGE, but it's | 107 | If 'never, deleted articles are marked with the IMAP \\Delete |
| 108 | not done by default on servers that doesn't support that command.") | 108 | flag but not automatically expunged. If 'immediately, deleted |
| 109 | articles are immediately expunged (this requires the server to | ||
| 110 | support the UID EXPUNGE command). If 'on-exit, deleted articles | ||
| 111 | are flagged, and all flagged articles are expunged when the | ||
| 112 | group is closed. | ||
| 113 | |||
| 114 | For backwards compatibility, this variable may also be set to t | ||
| 115 | or nil. If the server supports UID EXPUNGE, both t and nil are | ||
| 116 | equivalent to 'immediately. If the server does not support UID | ||
| 117 | EXPUNGE nil is equivalent to 'never, while t will immediately | ||
| 118 | expunge ALL articles that are currently flagged as deleted | ||
| 119 | (i.e., potentially not only the article that was just deleted).") | ||
| 109 | 120 | ||
| 110 | (defvoo nnimap-streaming t | 121 | (defvoo nnimap-streaming t |
| 111 | "If non-nil, try to use streaming commands with IMAP servers. | 122 | "If non-nil, try to use streaming commands with IMAP servers. |
| @@ -944,8 +955,11 @@ textual parts.") | |||
| 944 | articles))) | 955 | articles))) |
| 945 | (nreverse articles))) | 956 | (nreverse articles))) |
| 946 | 957 | ||
| 947 | (deffoo nnimap-close-group (_group &optional _server) | 958 | (deffoo nnimap-close-group (_group &optional server) |
| 948 | t) | 959 | (when (eq nnimap-expunge 'on-exit) |
| 960 | (nnoo-change-server 'nnimap server nil) | ||
| 961 | (with-current-buffer (nnimap-buffer) | ||
| 962 | (nnimap-command "EXPUNGE")))) | ||
| 949 | 963 | ||
| 950 | (deffoo nnimap-request-move-article (article group server accept-form | 964 | (deffoo nnimap-request-move-article (article group server accept-form |
| 951 | &optional _last | 965 | &optional _last |
| @@ -990,8 +1004,7 @@ textual parts.") | |||
| 990 | articles) | 1004 | articles) |
| 991 | ((and force | 1005 | ((and force |
| 992 | (eq nnmail-expiry-target 'delete)) | 1006 | (eq nnmail-expiry-target 'delete)) |
| 993 | (unless (nnimap-delete-article (gnus-compress-sequence articles)) | 1007 | (nnimap-delete-article (gnus-compress-sequence articles)) |
| 994 | (nnheader-message 7 "Article marked for deletion, but not expunged.")) | ||
| 995 | nil) | 1008 | nil) |
| 996 | (t | 1009 | (t |
| 997 | (let ((deletable-articles | 1010 | (let ((deletable-articles |
| @@ -1111,20 +1124,33 @@ If LIMIT, first try to limit the search to the N last articles." | |||
| 1111 | (nnimap-find-article-by-message-id group server message-id)))))))) | 1124 | (nnimap-find-article-by-message-id group server message-id)))))))) |
| 1112 | 1125 | ||
| 1113 | (defun nnimap-delete-article (articles) | 1126 | (defun nnimap-delete-article (articles) |
| 1127 | "Delete ARTICLES." | ||
| 1114 | (with-current-buffer (nnimap-buffer) | 1128 | (with-current-buffer (nnimap-buffer) |
| 1115 | (nnimap-command "UID STORE %s +FLAGS.SILENT (\\Deleted)" | 1129 | (nnimap-command "UID STORE %s +FLAGS.SILENT (\\Deleted)" |
| 1116 | (nnimap-article-ranges articles)) | 1130 | (nnimap-article-ranges articles)) |
| 1117 | (cond | 1131 | (cond |
| 1132 | ((eq nnimap-expunge 'immediately) | ||
| 1133 | (if (nnimap-capability "UIDPLUS") | ||
| 1134 | (nnimap-command "UID EXPUNGE %s" | ||
| 1135 | (nnimap-article-ranges articles)) | ||
| 1136 | (nnheader-message | ||
| 1137 | 3 (concat "nnimap-expunge set to 'immediately, but " | ||
| 1138 | "server doesn't support UIDPLUS")) | ||
| 1139 | nil)) | ||
| 1140 | |||
| 1141 | ((memq nnimap-expunge '(on-exit never)) nil) | ||
| 1142 | |||
| 1118 | ((nnimap-capability "UIDPLUS") | 1143 | ((nnimap-capability "UIDPLUS") |
| 1119 | (nnimap-command "UID EXPUNGE %s" | 1144 | (nnimap-command "UID EXPUNGE %s" |
| 1120 | (nnimap-article-ranges articles)) | 1145 | (nnimap-article-ranges articles))) |
| 1121 | t) | 1146 | |
| 1122 | (nnimap-expunge | 1147 | (nnimap-expunge |
| 1123 | (nnimap-command "EXPUNGE") | 1148 | (nnimap-command "EXPUNGE")) |
| 1124 | t) | 1149 | |
| 1125 | (t (gnus-message 7 (concat "nnimap: nnimap-expunge is not set and the " | 1150 | (t |
| 1126 | "server doesn't support UIDPLUS, so we won't " | 1151 | (nnheader-message |
| 1127 | "delete this article now")))))) | 1152 | 7 "Article marked for deletion, but not expunged.") |
| 1153 | nil)))) | ||
| 1128 | 1154 | ||
| 1129 | (deffoo nnimap-request-scan (&optional group server) | 1155 | (deffoo nnimap-request-scan (&optional group server) |
| 1130 | (when (and (nnimap-change-group nil server) | 1156 | (when (and (nnimap-change-group nil server) |
| @@ -2149,27 +2175,9 @@ Return the server's response to the SELECT or EXAMINE command." | |||
| 2149 | (nnimap-wait-for-response (caar sequences)) | 2175 | (nnimap-wait-for-response (caar sequences)) |
| 2150 | ;; And then mark the successful copy actions as deleted, | 2176 | ;; And then mark the successful copy actions as deleted, |
| 2151 | ;; and possibly expunge them. | 2177 | ;; and possibly expunge them. |
| 2152 | (nnimap-mark-and-expunge-incoming | 2178 | (nnimap-delete-article |
| 2153 | (nnimap-parse-copied-articles sequences))) | 2179 | (nnimap-parse-copied-articles sequences))) |
| 2154 | (nnimap-mark-and-expunge-incoming junk-articles))))))) | 2180 | (nnimap-delete-article junk-articles))))))) |
| 2155 | |||
| 2156 | (defun nnimap-mark-and-expunge-incoming (range) | ||
| 2157 | (when range | ||
| 2158 | (setq range (nnimap-article-ranges range)) | ||
| 2159 | (erase-buffer) | ||
| 2160 | (let ((sequence | ||
| 2161 | (nnimap-send-command | ||
| 2162 | "UID STORE %s +FLAGS.SILENT (\\Deleted)" range))) | ||
| 2163 | (cond | ||
| 2164 | ;; If the server supports it, we now delete the message we have | ||
| 2165 | ;; just copied over. | ||
| 2166 | ((nnimap-capability "UIDPLUS") | ||
| 2167 | (setq sequence (nnimap-send-command "UID EXPUNGE %s" range))) | ||
| 2168 | ;; If it doesn't support UID EXPUNGE, then we only expunge if the | ||
| 2169 | ;; user has configured it. | ||
| 2170 | (nnimap-expunge | ||
| 2171 | (setq sequence (nnimap-send-command "EXPUNGE")))) | ||
| 2172 | (nnimap-wait-for-response sequence)))) | ||
| 2173 | 2181 | ||
| 2174 | (defun nnimap-parse-copied-articles (sequences) | 2182 | (defun nnimap-parse-copied-articles (sequences) |
| 2175 | (let (sequence copied range) | 2183 | (let (sequence copied range) |