>From cd74921ce8e867dfe056d6aa94431269460822e2 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Sun, 12 Jul 2015 11:10:28 -0700 Subject: [PATCH 1/2] nnimap.el: factor out nnimap-group-to-imap * lisp/nnimap.el (nnimap-request-group-scan) (nnimap-request-create-group, nnimap-request-delete-group) (nnimap-request-rename-group, nnimap-request-move-article) (nnimap-process-expiry-targets) (nnimap-request-update-group-status) (nnimap-request-accept-article, nnimap-request-list) (nnimap-retrieve-group-data-early, nnimap-change-group) (nnimap-split-incoming-mail): use nnimap-group-to-imap. (nnimap-group-to-imap): new function to map Gnus group names to IMAP folder names. --- lisp/ChangeLog | 13 +++++++++++++ lisp/nnimap.el | 32 ++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 556be98..be5d3fb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,18 @@ 2015-07-12 Nikolaus Rath + * nnimap.el (nnimap-request-group-scan) + (nnimap-request-create-group, nnimap-request-delete-group) + (nnimap-request-rename-group, nnimap-request-move-article) + (nnimap-process-expiry-targets) + (nnimap-request-update-group-status) + (nnimap-request-accept-article, nnimap-request-list) + (nnimap-retrieve-group-data-early, nnimap-change-group) + (nnimap-split-incoming-mail): use nnimap-group-to-imap. + (nnimap-group-to-imap): new function to map Gnus group names to + IMAP folder names. + +2015-07-12 Nikolaus Rath + * nnimap.el (nnimap-open-connection-1): explicitly ask server for capabilities instead of relying on LOGIN response. diff --git a/lisp/nnimap.el b/lisp/nnimap.el index b24c3c5..19632ad 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -178,6 +178,10 @@ If non-nil, articles flagged as deleted (using the IMAP (defvar nnimap-inhibit-logging nil) +(defun nnimap-group-to-imap (group) + "Convert Gnus group name to IMAP mailbox name" + (utf7-encode group t)) + (defun nnimap-buffer () (nnimap-find-process-buffer nntp-server-buffer)) @@ -859,7 +863,7 @@ If non-nil, articles flagged as deleted (using the IMAP (with-current-buffer (nnimap-buffer) (erase-buffer) (let ((group-sequence - (nnimap-send-command "SELECT %S" (utf7-encode group t))) + (nnimap-send-command "SELECT %S" (nnimap-group-to-imap group))) (flag-sequence (nnimap-send-command "UID FETCH 1:* FLAGS"))) (setf (nnimap-group nnimap-object) group) @@ -891,13 +895,13 @@ If non-nil, articles flagged as deleted (using the IMAP (setq group (nnimap-decode-gnus-group group)) (when (nnimap-change-group nil server) (with-current-buffer (nnimap-buffer) - (car (nnimap-command "CREATE %S" (utf7-encode group t)))))) + (car (nnimap-command "CREATE %S" (nnimap-group-to-imap group)))))) (deffoo nnimap-request-delete-group (group &optional force server) (setq group (nnimap-decode-gnus-group group)) (when (nnimap-change-group nil server) (with-current-buffer (nnimap-buffer) - (car (nnimap-command "DELETE %S" (utf7-encode group t)))))) + (car (nnimap-command "DELETE %S" (nnimap-group-to-imap group)))))) (deffoo nnimap-request-rename-group (group new-name &optional server) (setq group (nnimap-decode-gnus-group group)) @@ -905,7 +909,7 @@ If non-nil, articles flagged as deleted (using the IMAP (with-current-buffer (nnimap-buffer) (nnimap-unselect-group) (car (nnimap-command "RENAME %S %S" - (utf7-encode group t) (utf7-encode new-name t)))))) + (nnimap-group-to-imap group) (nnimap-group-to-imap new-name)))))) (defun nnimap-unselect-group () ;; Make sure we don't have this group open read/write by asking @@ -966,7 +970,7 @@ If non-nil, articles flagged as deleted (using the IMAP "UID MOVE %d %S" "UID COPY %d %S")) (result (nnimap-command command article - (utf7-encode internal-move-group t)))) + (nnimap-group-to-imap internal-move-group)))) (when (and (car result) (not can-move)) (nnimap-delete-article article)) (cons internal-move-group @@ -1032,7 +1036,7 @@ If non-nil, articles flagged as deleted (using the IMAP "UID MOVE %s %S" "UID COPY %s %S") (nnimap-article-ranges (gnus-compress-sequence articles)) - (utf7-encode (gnus-group-real-name nnmail-expiry-target) t)) + (nnimap-group-to-imap (gnus-group-real-name nnmail-expiry-target))) (set (if can-move 'deleted-articles 'articles-to-delete) articles)))) t) (t @@ -1172,7 +1176,7 @@ If sync is non-nil, wait for server response." (unsubscribe "UNSUBSCRIBE"))))) (when command (with-current-buffer (nnimap-buffer) - (nnimap-command "%s %S" (cadr command) (utf7-encode group t))))))) + (nnimap-command "%s %S" (cadr command) (nnimap-group-to-imap group))))))) (deffoo nnimap-request-set-mark (group actions &optional server) (setq group (nnimap-decode-gnus-group group)) @@ -1227,7 +1231,7 @@ If sync is non-nil, wait for server response." (nnimap-unselect-group)) (erase-buffer) (setq sequence (nnimap-send-command - "APPEND %S {%d}" (utf7-encode group t) + "APPEND %S {%d}" (nnimap-group-to-imap group) (length message))) (unless nnimap-streaming (nnimap-wait-for-connection "^[+]")) @@ -1354,7 +1358,7 @@ If sync is non-nil, wait for server response." (dolist (group groups) (setf (nnimap-examined nnimap-object) group) (push (list (nnimap-send-command "EXAMINE %S" - (utf7-encode group t)) + (nnimap-group-to-imap group)) group) sequences)) (nnimap-wait-for-response (caar sequences)) @@ -1426,7 +1430,7 @@ If sync is non-nil, wait for server response." unexist) (push (list (nnimap-send-command "EXAMINE %S (%s (%s %s))" - (utf7-encode group t) + (nnimap-group-to-imap group) (nnimap-quirk "QRESYNC") uidvalidity modseq) 'qresync @@ -1448,7 +1452,7 @@ If sync is non-nil, wait for server response." (incf (nnimap-initial-resync nnimap-object)) (setq start 1)) (push (list (nnimap-send-command "%s %S" command - (utf7-encode group t)) + (nnimap-group-to-imap group)) (nnimap-send-command "UID FETCH %d:* FLAGS" start) start group command) sequences)))) @@ -1878,7 +1882,7 @@ Return the server's response to the SELECT or EXAMINE command." (if read-only "EXAMINE" "SELECT") - (utf7-encode group t)))) + (nnimap-group-to-imap group)))) (when (car result) (setf (nnimap-group nnimap-object) group (nnimap-select-result nnimap-object) result) @@ -2135,7 +2139,7 @@ Return the server's response to the SELECT or EXAMINE command." (dolist (spec specs) (when (and (not (member (car spec) groups)) (not (eq (car spec) 'junk))) - (nnimap-command "CREATE %S" (utf7-encode (car spec) t)))) + (nnimap-command "CREATE %S" (nnimap-group-to-imap (car spec))))) ;; Then copy over all the messages. (erase-buffer) (dolist (spec specs) @@ -2151,7 +2155,7 @@ Return the server's response to the SELECT or EXAMINE command." "UID MOVE %d %S" "UID COPY %s %S") (nnimap-article-ranges ranges) - (utf7-encode group t)) + (nnimap-group-to-imap group)) ranges) sequences))))) ;; Wait for the last COPY response... -- 2.1.4