aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2011-02-07 13:03:22 +0000
committerKatsumi Yamaoka2011-02-07 13:03:22 +0000
commit41d579ce4a2a86428f200788df4b15b936aa5076 (patch)
tree4f5ef71b0ce9a6477384c94c20e15edf1b514a00
parent1ff98217da213c4b933bbb9e70bf6f18fbcfc0f8 (diff)
downloademacs-41d579ce4a2a86428f200788df4b15b936aa5076.tar.gz
emacs-41d579ce4a2a86428f200788df4b15b936aa5076.zip
nnimap.el (nnimap-update-info): Refactor slightly.
(nnimap-update-info): Tell Gnus whether there are any \Recent messages. (nnimap-update-info): Clean up slightly. (nnimap-quirk): Add quirk for Gmail IMAP which bugs out on NUL characters. (nnimap-process-quirk): Renamed function to avoid collision. (nnimap-update-info): Fix macrology bug-out.
-rw-r--r--lisp/gnus/ChangeLog10
-rw-r--r--lisp/gnus/nnimap.el89
2 files changed, 71 insertions, 28 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 1ff45b69c2b..a18f145cb68 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,13 @@
12011-02-07 Lars Ingebrigtsen <larsi@gnus.org>
2
3 * nnimap.el (nnimap-update-info): Refactor slightly.
4 (nnimap-update-info): Tell Gnus whether there are any \Recent messages.
5 (nnimap-update-info): Clean up slightly.
6 (nnimap-quirk): Add quirk for Gmail IMAP which bugs out on NUL
7 characters.
8 (nnimap-process-quirk): Renamed function to avoid collision.
9 (nnimap-update-info): Fix macrology bug-out.
10
12011-02-06 Lars Ingebrigtsen <larsi@gnus.org> 112011-02-06 Lars Ingebrigtsen <larsi@gnus.org>
2 12
3 * nntp.el (nntp-finish-retrieve-group-infos): Protect against the first 13 * nntp.el (nntp-finish-retrieve-group-infos): Protect against the first
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index b50d656aa25..127082bc28f 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -969,30 +969,54 @@ textual parts.")
969 (nnimap-add-cr) 969 (nnimap-add-cr)
970 (setq message (buffer-substring-no-properties (point-min) (point-max))) 970 (setq message (buffer-substring-no-properties (point-min) (point-max)))
971 (with-current-buffer (nnimap-buffer) 971 (with-current-buffer (nnimap-buffer)
972 ;; If we have this group open read-only, then unselect it 972 (when (setq message (nnimap-process-quirk "OK Gimap " 'append message))
973 ;; before appending to it. 973 ;; If we have this group open read-only, then unselect it
974 (when (equal (nnimap-examined nnimap-object) group) 974 ;; before appending to it.
975 (nnimap-unselect-group)) 975 (when (equal (nnimap-examined nnimap-object) group)
976 (erase-buffer) 976 (nnimap-unselect-group))
977 (setq sequence (nnimap-send-command 977 (erase-buffer)
978 "APPEND %S {%d}" (utf7-encode group t) 978 (setq sequence (nnimap-send-command
979 (length message))) 979 "APPEND %S {%d}" (utf7-encode group t)
980 (unless nnimap-streaming 980 (length message)))
981 (nnimap-wait-for-connection "^[+]")) 981 (unless nnimap-streaming
982 (process-send-string (get-buffer-process (current-buffer)) message) 982 (nnimap-wait-for-connection "^[+]"))
983 (process-send-string (get-buffer-process (current-buffer)) 983 (process-send-string (get-buffer-process (current-buffer)) message)
984 (if (nnimap-newlinep nnimap-object) 984 (process-send-string (get-buffer-process (current-buffer))
985 "\n" 985 (if (nnimap-newlinep nnimap-object)
986 "\r\n")) 986 "\n"
987 (let ((result (nnimap-get-response sequence))) 987 "\r\n"))
988 (if (not (nnimap-ok-p result)) 988 (let ((result (nnimap-get-response sequence)))
989 (progn 989 (if (not (nnimap-ok-p result))
990 (nnheader-report 'nnimap "%s" result) 990 (progn
991 nil) 991 (nnheader-report 'nnimap "%s" result)
992 (cons group 992 nil)
993 (or (nnimap-find-uid-response "APPENDUID" (car result)) 993 (cons group
994 (nnimap-find-article-by-message-id 994 (or (nnimap-find-uid-response "APPENDUID" (car result))
995 group message-id))))))))) 995 (nnimap-find-article-by-message-id
996 group message-id))))))))))
997
998(defun nnimap-process-quirk (greeting-match type data)
999 (when (and (nnimap-greeting nnimap-object)
1000 (string-match "OK Gimap " (nnimap-greeting nnimap-object))
1001 (eq type 'append)
1002 (string-match "\000" data))
1003 (let ((choice (gnus-multiple-choice
1004 "Message contains NUL characters. Delete, continue, abort? "
1005 '((?d "Delete NUL characters")
1006 (?c "Try to APPEND the message as is")
1007 (?a "Abort")))))
1008 (cond
1009 ((eq choice ?a)
1010 (nnheader-report 'nnimap "Aborted APPEND due to NUL characters"))
1011 ((eq choice ?c)
1012 data)
1013 (t
1014 (with-temp-buffer
1015 (insert data)
1016 (goto-char (point-min))
1017 (while (search-forward "\000" nil t)
1018 (replace-match "" t t))
1019 (buffer-string)))))))
996 1020
997(defun nnimap-ok-p (value) 1021(defun nnimap-ok-p (value)
998 (and (consp value) 1022 (and (consp value)
@@ -1249,10 +1273,9 @@ textual parts.")
1249 (t 1273 (t
1250 ;; No articles and no uidnext. 1274 ;; No articles and no uidnext.
1251 nil))) 1275 nil)))
1252 (gnus-set-active 1276 (gnus-set-active group
1253 group 1277 (cons (car active)
1254 (cons (car active) 1278 (or high (1- uidnext)))))
1255 (or high (1- uidnext)))))
1256 ;; See whether this is a read-only group. 1279 ;; See whether this is a read-only group.
1257 (unless (eq permanent-flags 'not-scanned) 1280 (unless (eq permanent-flags 'not-scanned)
1258 (gnus-group-set-parameter 1281 (gnus-group-set-parameter
@@ -1316,6 +1339,16 @@ textual parts.")
1316 (when new-marks 1339 (when new-marks
1317 (push (cons (car type) new-marks) marks))))) 1340 (push (cons (car type) new-marks) marks)))))
1318 (gnus-info-set-marks info marks t)))) 1341 (gnus-info-set-marks info marks t))))
1342 ;; Tell Gnus whether there are any \Recent messages in any of
1343 ;; the groups.
1344 (let ((recent (cdr (assoc '%Recent flags))))
1345 (when (and active recent)
1346 (while recent
1347 (when (> (car recent) (cdr active))
1348 (push (list (cons (gnus-group-real-name group) 0))
1349 nnmail-split-history)
1350 (setq recent nil))
1351 (pop recent))))
1319 ;; Note the active level for the next run-through. 1352 ;; Note the active level for the next run-through.
1320 (gnus-group-set-parameter info 'active (gnus-active group)) 1353 (gnus-group-set-parameter info 'active (gnus-active group))
1321 (gnus-group-set-parameter info 'uidvalidity uidvalidity) 1354 (gnus-group-set-parameter info 'uidvalidity uidvalidity)