aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2017-01-25 01:18:43 +0100
committerLars Ingebrigtsen2017-01-25 01:18:43 +0100
commitf580ea195bfdef71de1642311f27c2aff1e4b41c (patch)
tree4c52e0376fa8149cdbf7b770a480f3b8b46305b8
parent4e9baea6aba1633074889339dcc7cdc9d73880d3 (diff)
downloademacs-f580ea195bfdef71de1642311f27c2aff1e4b41c.tar.gz
emacs-f580ea195bfdef71de1642311f27c2aff1e4b41c.zip
Revert "nnimap.el: support additional expunge options"
This reverts commit 4e9baea6aba1633074889339dcc7cdc9d73880d3. The patch broke fetching new mail: Debugger entered--Lisp error: (error "Format specifier doesn’t match argument type") format("%d .*\n" (t ("OK" ("HIGHESTMODSEQ" "914696") "Expunge" "completed.") ("VANISHED" "1825937") ("0" "RECENT"))) (looking-at (format "%d .*\n" sequence)) (not (looking-at (format "%d .*\n" sequence))) (progn (while (and (not (bobp)) (progn (forward-line -1) (looking-at "\\*\\|[0-9]+ OK NOOP")))) (not (looking-at (format "%d .*\n" sequence))))
-rw-r--r--doc/misc/gnus.texi16
-rw-r--r--etc/NEWS10
-rw-r--r--lisp/gnus/nnimap.el87
3 files changed, 40 insertions, 73 deletions
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index e8524fb03f0..05159d4b2f7 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -14273,19 +14273,9 @@ specific login method to be used, you can set this variable to either
14273@code{plain} or @code{cram-md5}. 14273@code{plain} or @code{cram-md5}.
14274 14274
14275@item nnimap-expunge 14275@item nnimap-expunge
14276When to expunge deleted messages. If @code{never}, deleted articles 14276If non-@code{nil}, expunge articles after deleting them. This is always done
14277are marked with the IMAP @code{\\Delete} flag but not automatically 14277if the server supports UID EXPUNGE, but it's not done by default on
14278expunged. If @code{immediately}, deleted articles are immediately expunged 14278servers that doesn't support that command.
14279(this requires the server to support the UID EXPUNGE command). If
14280@code{on-exit}, deleted articles are flagged, and all flagged articles are
14281expunged when the group is closed.
14282
14283For backwards compatibility, this variable may also be set to t
14284or nil. If the server supports UID EXPUNGE, both t and nil are
14285equivalent to @code{immediately}. If the server does not support UID
14286EXPUNGE nil is equivalent to @code{never}, while t will immediately
14287expunge ALL articles that are currently flagged as deleted
14288(i.e., potentially not only the article that was just deleted).
14289 14279
14290@item nnimap-streaming 14280@item nnimap-streaming
14291Virtually all @acronym{IMAP} server support fast streaming of data. 14281Virtually all @acronym{IMAP} server support fast streaming of data.
diff --git a/etc/NEWS b/etc/NEWS
index e5ee40cbe4b..ca66df62610 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -81,16 +81,6 @@ for '--daemon'.
81* Changes in Emacs 26.1 81* Changes in Emacs 26.1
82 82
83+++ 83+++
84** The Gnus user variable 'nnimap-expunge' supports three new values:
85'never' for never expunging messages, 'immediately' for immediately
86expunging deleted messages, and 'on-exit' to expunge deleted articles
87when exiting the group's summary buffer. Setting 'nnimap-expunge' to
88'nil' or 't' is still supported but not recommended, since it may
89result in Gnus expunging all messages that have been flagged as
90deleted by any IMAP client (rather than just those that have been
91deleted by Gnus).
92
93+++
94** The new function 'mapbacktrace' applies a function to all frames of 84** The new function 'mapbacktrace' applies a function to all frames of
95the current stack trace. 85the current stack trace.
96 86
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 931ec312083..700e86a0c57 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -92,21 +92,10 @@ Uses the same syntax as `nnmail-split-methods'.")
92Possible choices are nil (use default methods), `anonymous', 92Possible choices are nil (use default methods), `anonymous',
93`login', `plain' and `cram-md5'.") 93`login', `plain' and `cram-md5'.")
94 94
95(defvoo nnimap-expunge 'on-exit 95(defvoo nnimap-expunge t
96 "When to expunge deleted messages. 96 "If non-nil, expunge articles after deleting them.
97If 'never, deleted articles are marked with the IMAP \\Delete 97This is always done if the server supports UID EXPUNGE, but it's
98flag but not automatically expunged. If 'immediately, deleted 98not done by default on servers that doesn't support that command.")
99articles are immediately expunged (this requires the server to
100support the UID EXPUNGE command). If 'on-exit, deleted articles
101are flagged, and all flagged articles are expunged when the
102group is closed.
103
104For backwards compatibility, this variable may also be set to t
105or nil. If the server supports UID EXPUNGE, both t and nil are
106equivalent to 'immediately. If the server does not support UID
107EXPUNGE nil is equivalent to 'never, while t will immediately
108expunge ALL articles that are currently flagged as deleted
109(i.e., potentially not only the article that was just deleted).")
110 99
111(defvoo nnimap-streaming t 100(defvoo nnimap-streaming t
112 "If non-nil, try to use streaming commands with IMAP servers. 101 "If non-nil, try to use streaming commands with IMAP servers.
@@ -921,12 +910,8 @@ textual parts.")
921 articles))) 910 articles)))
922 (nreverse articles))) 911 (nreverse articles)))
923 912
924(deffoo nnimap-close-group (_group &optional server) 913(deffoo nnimap-close-group (_group &optional _server)
925 (when (eq nnimap-expunge 'on-exit) 914 t)
926 (nnoo-change-server 'nnimap server nil)
927 (with-current-buffer (nnimap-buffer)
928 (nnimap-wait-for-response
929 (nnimap-send-command "EXPUNGE")))))
930 915
931(deffoo nnimap-request-move-article (article group server accept-form 916(deffoo nnimap-request-move-article (article group server accept-form
932 &optional _last 917 &optional _last
@@ -975,7 +960,8 @@ textual parts.")
975 articles) 960 articles)
976 ((and force 961 ((and force
977 (eq nnmail-expiry-target 'delete)) 962 (eq nnmail-expiry-target 'delete))
978 (nnimap-delete-article (gnus-compress-sequence articles)) 963 (unless (nnimap-delete-article (gnus-compress-sequence articles))
964 (nnheader-message 7 "Article marked for deletion, but not expunged."))
979 nil) 965 nil)
980 (t 966 (t
981 (let ((deletable-articles 967 (let ((deletable-articles
@@ -1098,38 +1084,21 @@ If LIMIT, first try to limit the search to the N last articles."
1098 (when (and limit number-of-article) 1084 (when (and limit number-of-article)
1099 (nnimap-find-article-by-message-id group server message-id)))))))) 1085 (nnimap-find-article-by-message-id group server message-id))))))))
1100 1086
1101(defun nnimap-delete-article (articles &optional sync) 1087(defun nnimap-delete-article (articles)
1102 "Delete ARTICLES.
1103
1104If sync is non-nil, wait for server response."
1105 (with-current-buffer (nnimap-buffer) 1088 (with-current-buffer (nnimap-buffer)
1106 (nnimap-command "UID STORE %s +FLAGS.SILENT (\\Deleted)" 1089 (nnimap-command "UID STORE %s +FLAGS.SILENT (\\Deleted)"
1107 (nnimap-article-ranges articles)) 1090 (nnimap-article-ranges articles))
1108 (let ((sequence
1109 (cond 1091 (cond
1110 ((eq nnimap-expunge 'immediately) 1092 ((nnimap-capability "UIDPLUS")
1111 (if (nnimap-capability "UIDPLUS")
1112 (nnimap-command "UID EXPUNGE %s" 1093 (nnimap-command "UID EXPUNGE %s"
1113 (nnimap-article-ranges articles)) 1094 (nnimap-article-ranges articles))
1114 (nnheader-message 1095 t)
1115 3 (concat "nnimap-expunge set to 'immediately, but "
1116 "server doesn't support UIDPLUS"))))
1117
1118 ((memq nnimap-expunge '(on-exit never)) nil)
1119
1120 ((nnimap-capability "UIDPLUS")
1121 (nnimap-command "UID EXPUNGE %s"
1122 (nnimap-article-ranges articles)))
1123
1124 (nnimap-expunge 1096 (nnimap-expunge
1125 (nnimap-command "EXPUNGE")) 1097 (nnimap-command "EXPUNGE")
1126 1098 t)
1127 (t 1099 (t (gnus-message 7 (concat "nnimap: nnimap-expunge is not set and the "
1128 (nnheader-message 1100 "server doesn't support UIDPLUS, so we won't "
1129 7 "Article marked for deletion, but not expunged."))))) 1101 "delete this article now"))))))
1130
1131 (if (and sync sequence)
1132 (nnimap-wait-for-response sequence)))))
1133 1102
1134(deffoo nnimap-request-scan (&optional group server) 1103(deffoo nnimap-request-scan (&optional group server)
1135 (when group 1104 (when group
@@ -2149,9 +2118,27 @@ Return the server's response to the SELECT or EXAMINE command."
2149 (nnimap-wait-for-response (caar sequences)) 2118 (nnimap-wait-for-response (caar sequences))
2150 ;; And then mark the successful copy actions as deleted, 2119 ;; And then mark the successful copy actions as deleted,
2151 ;; and possibly expunge them. 2120 ;; and possibly expunge them.
2152 (nnimap-delete-article 2121 (nnimap-mark-and-expunge-incoming
2153 (nnimap-parse-copied-articles sequences) t)) 2122 (nnimap-parse-copied-articles sequences)))
2154 (nnimap-delete-article junk-articles t))))))) 2123 (nnimap-mark-and-expunge-incoming junk-articles)))))))
2124
2125(defun nnimap-mark-and-expunge-incoming (range)
2126 (when range
2127 (setq range (nnimap-article-ranges range))
2128 (erase-buffer)
2129 (let ((sequence
2130 (nnimap-send-command
2131 "UID STORE %s +FLAGS.SILENT (\\Deleted)" range)))
2132 (cond
2133 ;; If the server supports it, we now delete the message we have
2134 ;; just copied over.
2135 ((nnimap-capability "UIDPLUS")
2136 (setq sequence (nnimap-send-command "UID EXPUNGE %s" range)))
2137 ;; If it doesn't support UID EXPUNGE, then we only expunge if the
2138 ;; user has configured it.
2139 (nnimap-expunge
2140 (setq sequence (nnimap-send-command "EXPUNGE"))))
2141 (nnimap-wait-for-response sequence))))
2155 2142
2156(defun nnimap-parse-copied-articles (sequences) 2143(defun nnimap-parse-copied-articles (sequences)
2157 (let (sequence copied range) 2144 (let (sequence copied range)