aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2018-07-23 09:01:24 +0200
committerLars Ingebrigtsen2018-07-23 09:01:24 +0200
commit216b9b2dbff4cd6843d988c1e2df81b1e02a52fd (patch)
treefcba2e111e394e9e53c406d57f1594c9c44d9e00
parent8f3bca3ad513549af552b321aaca81e9e635857b (diff)
downloademacs-216b9b2dbff4cd6843d988c1e2df81b1e02a52fd.tar.gz
emacs-216b9b2dbff4cd6843d988c1e2df81b1e02a52fd.zip
Revert "Make nnimap support IMAP namespaces"
This reverts commit 7b5b3ddb2dfa98d640aff7b5b160f777e22cc794. Insufficiently tested before committing -- bugs out several places when not using namespaces.
-rw-r--r--doc/misc/gnus.texi6
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/gnus/nnimap.el90
3 files changed, 27 insertions, 74 deletions
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index cd97cff2a05..6793ed2e9f1 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -14320,12 +14320,6 @@ fetch all textual parts, while leaving the rest on the server.
14320If non-@code{nil}, record all @acronym{IMAP} commands in the 14320If non-@code{nil}, record all @acronym{IMAP} commands in the
14321@samp{"*imap log*"} buffer. 14321@samp{"*imap log*"} buffer.
14322 14322
14323@item nnimap-use-namespaces
14324If non-@code{nil}, omit the IMAP namespace prefix in nnimap group
14325names. If your IMAP mailboxes are called something like @samp{INBOX}
14326and @samp{INBOX.Lists.emacs}, but you'd like the nnimap group names to
14327be @samp{INBOX} and @samp{Lists.emacs}, you should enable this option.
14328
14329@end table 14323@end table
14330 14324
14331 14325
diff --git a/etc/NEWS b/etc/NEWS
index 57b51f61b60..fc2a5d4c039 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -46,11 +46,6 @@ option --enable-check-lisp-object-type is therefore no longer as
46useful and so is no longer enabled by default in developer builds, 46useful and so is no longer enabled by default in developer builds,
47to reduce differences between developer and production builds. 47to reduce differences between developer and production builds.
48 48
49** Gnus
50
51+++
52*** The nnimap backend now has support for IMAP namespaces.
53
54 49
55* Startup Changes in Emacs 27.1 50* Startup Changes in Emacs 27.1
56 51
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index af7899f7897..3b397319272 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -55,13 +55,6 @@
55If nnimap-stream is `ssl', this will default to `imaps'. If not, 55If nnimap-stream is `ssl', this will default to `imaps'. If not,
56it will default to `imap'.") 56it will default to `imap'.")
57 57
58(defvoo nnimap-use-namespaces nil
59 "Whether to use IMAP namespaces.
60If in Gnus your folder names in all start with (e.g.) `INBOX',
61you probably want to set this to t. The effects of this are
62purely cosmetical, but changing this variable will affect the
63names of your nnimap groups. ")
64
65(defvoo nnimap-stream 'undecided 58(defvoo nnimap-stream 'undecided
66 "How nnimap talks to the IMAP server. 59 "How nnimap talks to the IMAP server.
67The value should be either `undecided', `ssl' or `tls', 60The value should be either `undecided', `ssl' or `tls',
@@ -117,8 +110,6 @@ some servers.")
117 110
118(defvoo nnimap-current-infos nil) 111(defvoo nnimap-current-infos nil)
119 112
120(defvoo nnimap-namespace nil)
121
122(defun nnimap-decode-gnus-group (group) 113(defun nnimap-decode-gnus-group (group)
123 (decode-coding-string group 'utf-8)) 114 (decode-coding-string group 'utf-8))
124 115
@@ -175,18 +166,6 @@ textual parts.")
175 166
176(defvar nnimap-inhibit-logging nil) 167(defvar nnimap-inhibit-logging nil)
177 168
178(defun nnimap-group-to-imap (group)
179 "Convert Gnus group name to IMAP mailbox name."
180 (let* ((inbox (substring nnimap-namespace 0 -1)))
181 (utf7-encode
182 (cond ((or (not nnimap-namespace)
183 (string-equal group inbox))
184 group)
185 ((string-prefix-p "#" group)
186 (substring group 1))
187 (t
188 (concat nnimap-namespace group))) t)))
189
190(defun nnimap-buffer () 169(defun nnimap-buffer ()
191 (nnimap-find-process-buffer nntp-server-buffer)) 170 (nnimap-find-process-buffer nntp-server-buffer))
192 171
@@ -463,8 +442,7 @@ textual parts.")
463 (props (cdr stream-list)) 442 (props (cdr stream-list))
464 (greeting (plist-get props :greeting)) 443 (greeting (plist-get props :greeting))
465 (capabilities (plist-get props :capabilities)) 444 (capabilities (plist-get props :capabilities))
466 (stream-type (plist-get props :type)) 445 (stream-type (plist-get props :type)))
467 (server (nnoo-current-server 'nnimap)))
468 (when (and stream (not (memq (process-status stream) '(open run)))) 446 (when (and stream (not (memq (process-status stream) '(open run))))
469 (setq stream nil)) 447 (setq stream nil))
470 448
@@ -497,7 +475,9 @@ textual parts.")
497 ;; the virtual server name and the address 475 ;; the virtual server name and the address
498 (nnimap-credentials 476 (nnimap-credentials
499 (gnus-delete-duplicates 477 (gnus-delete-duplicates
500 (list server nnimap-address)) 478 (list
479 (nnoo-current-server 'nnimap)
480 nnimap-address))
501 ports 481 ports
502 nnimap-user)))) 482 nnimap-user))))
503 (setq nnimap-object nil) 483 (setq nnimap-object nil)
@@ -516,17 +496,8 @@ textual parts.")
516 (dolist (response (cddr (nnimap-command "CAPABILITY"))) 496 (dolist (response (cddr (nnimap-command "CAPABILITY")))
517 (when (string= "CAPABILITY" (upcase (car response))) 497 (when (string= "CAPABILITY" (upcase (car response)))
518 (setf (nnimap-capabilities nnimap-object) 498 (setf (nnimap-capabilities nnimap-object)
519 (mapcar #'upcase (cdr response))))) 499 (mapcar #'upcase (cdr response))))))
520 (when (and nnimap-use-namespaces 500 ;; If the login failed, then forget the credentials
521 (nnimap-capability "NAMESPACE"))
522 (erase-buffer)
523 (nnimap-wait-for-response (nnimap-send-command "NAMESPACE"))
524 (let ((response (nnimap-last-response-string)))
525 (when (string-match
526 "^\\*\\W+NAMESPACE\\W+((\"\\([^\"\n]+\\)\"\\W+\"\\(.\\)\"))\\W+"
527 response)
528 (setq nnimap-namespace (match-string 1 response))))))
529 ;; If the login failed, then forget the credentials
530 ;; that are now possibly cached. 501 ;; that are now possibly cached.
531 (dolist (host (list (nnoo-current-server 'nnimap) 502 (dolist (host (list (nnoo-current-server 'nnimap)
532 nnimap-address)) 503 nnimap-address))
@@ -866,7 +837,7 @@ textual parts.")
866 (with-current-buffer (nnimap-buffer) 837 (with-current-buffer (nnimap-buffer)
867 (erase-buffer) 838 (erase-buffer)
868 (let ((group-sequence 839 (let ((group-sequence
869 (nnimap-send-command "SELECT %S" (nnimap-group-to-imap group))) 840 (nnimap-send-command "SELECT %S" (utf7-encode group t)))
870 (flag-sequence 841 (flag-sequence
871 (nnimap-send-command "UID FETCH 1:* FLAGS"))) 842 (nnimap-send-command "UID FETCH 1:* FLAGS")))
872 (setf (nnimap-group nnimap-object) group) 843 (setf (nnimap-group nnimap-object) group)
@@ -899,13 +870,13 @@ textual parts.")
899 (setq group (nnimap-decode-gnus-group group)) 870 (setq group (nnimap-decode-gnus-group group))
900 (when (nnimap-change-group nil server) 871 (when (nnimap-change-group nil server)
901 (with-current-buffer (nnimap-buffer) 872 (with-current-buffer (nnimap-buffer)
902 (car (nnimap-command "CREATE %S" (nnimap-group-to-imap group)))))) 873 (car (nnimap-command "CREATE %S" (utf7-encode group t))))))
903 874
904(deffoo nnimap-request-delete-group (group &optional _force server) 875(deffoo nnimap-request-delete-group (group &optional _force server)
905 (setq group (nnimap-decode-gnus-group group)) 876 (setq group (nnimap-decode-gnus-group group))
906 (when (nnimap-change-group nil server) 877 (when (nnimap-change-group nil server)
907 (with-current-buffer (nnimap-buffer) 878 (with-current-buffer (nnimap-buffer)
908 (car (nnimap-command "DELETE %S" (nnimap-group-to-imap group)))))) 879 (car (nnimap-command "DELETE %S" (utf7-encode group t))))))
909 880
910(deffoo nnimap-request-rename-group (group new-name &optional server) 881(deffoo nnimap-request-rename-group (group new-name &optional server)
911 (setq group (nnimap-decode-gnus-group group)) 882 (setq group (nnimap-decode-gnus-group group))
@@ -913,7 +884,7 @@ textual parts.")
913 (with-current-buffer (nnimap-buffer) 884 (with-current-buffer (nnimap-buffer)
914 (nnimap-unselect-group) 885 (nnimap-unselect-group)
915 (car (nnimap-command "RENAME %S %S" 886 (car (nnimap-command "RENAME %S %S"
916 (nnimap-group-to-imap group) (nnimap-group-to-imap new-name)))))) 887 (utf7-encode group t) (utf7-encode new-name t))))))
917 888
918(defun nnimap-unselect-group () 889(defun nnimap-unselect-group ()
919 ;; Make sure we don't have this group open read/write by asking 890 ;; Make sure we don't have this group open read/write by asking
@@ -973,7 +944,7 @@ textual parts.")
973 "UID COPY %d %S")) 944 "UID COPY %d %S"))
974 (result (nnimap-command 945 (result (nnimap-command
975 command article 946 command article
976 (nnimap-group-to-imap internal-move-group)))) 947 (utf7-encode internal-move-group t))))
977 (when (and (car result) (not can-move)) 948 (when (and (car result) (not can-move))
978 (nnimap-delete-article article)) 949 (nnimap-delete-article article))
979 (cons internal-move-group 950 (cons internal-move-group
@@ -1040,7 +1011,7 @@ textual parts.")
1040 "UID MOVE %s %S" 1011 "UID MOVE %s %S"
1041 "UID COPY %s %S") 1012 "UID COPY %s %S")
1042 (nnimap-article-ranges (gnus-compress-sequence articles)) 1013 (nnimap-article-ranges (gnus-compress-sequence articles))
1043 (nnimap-group-to-imap (gnus-group-real-name nnmail-expiry-target))) 1014 (utf7-encode (gnus-group-real-name nnmail-expiry-target) t))
1044 (set (if can-move 'deleted-articles 'articles-to-delete) articles)))) 1015 (set (if can-move 'deleted-articles 'articles-to-delete) articles))))
1045 t) 1016 t)
1046 (t 1017 (t
@@ -1165,7 +1136,7 @@ If LIMIT, first try to limit the search to the N last articles."
1165 (unsubscribe "UNSUBSCRIBE"))))) 1136 (unsubscribe "UNSUBSCRIBE")))))
1166 (when command 1137 (when command
1167 (with-current-buffer (nnimap-buffer) 1138 (with-current-buffer (nnimap-buffer)
1168 (nnimap-command "%s %S" (cadr command) (nnimap-group-to-imap group))))))) 1139 (nnimap-command "%s %S" (cadr command) (utf7-encode group t)))))))
1169 1140
1170(deffoo nnimap-request-set-mark (group actions &optional server) 1141(deffoo nnimap-request-set-mark (group actions &optional server)
1171 (setq group (nnimap-decode-gnus-group group)) 1142 (setq group (nnimap-decode-gnus-group group))
@@ -1220,7 +1191,7 @@ If LIMIT, first try to limit the search to the N last articles."
1220 (nnimap-unselect-group)) 1191 (nnimap-unselect-group))
1221 (erase-buffer) 1192 (erase-buffer)
1222 (setq sequence (nnimap-send-command 1193 (setq sequence (nnimap-send-command
1223 "APPEND %S {%d}" (nnimap-group-to-imap group) 1194 "APPEND %S {%d}" (utf7-encode group t)
1224 (length message))) 1195 (length message)))
1225 (unless nnimap-streaming 1196 (unless nnimap-streaming
1226 (nnimap-wait-for-connection "^[+]")) 1197 (nnimap-wait-for-connection "^[+]"))
@@ -1300,11 +1271,8 @@ If LIMIT, first try to limit the search to the N last articles."
1300 1271
1301(defun nnimap-get-groups () 1272(defun nnimap-get-groups ()
1302 (erase-buffer) 1273 (erase-buffer)
1303 (let* ((sequence (nnimap-send-command "LIST \"\" \"*\"")) 1274 (let ((sequence (nnimap-send-command "LIST \"\" \"*\""))
1304 (prefix nnimap-namespace) 1275 groups)
1305 (prefix-len (length prefix))
1306 (inbox (substring prefix 0 -1))
1307 groups)
1308 (nnimap-wait-for-response sequence) 1276 (nnimap-wait-for-response sequence)
1309 (subst-char-in-region (point-min) (point-max) 1277 (subst-char-in-region (point-min) (point-max)
1310 ?\\ ?% t) 1278 ?\\ ?% t)
@@ -1321,15 +1289,11 @@ If LIMIT, first try to limit the search to the N last articles."
1321 (skip-chars-backward " \r\"") 1289 (skip-chars-backward " \r\"")
1322 (point))))) 1290 (point)))))
1323 (unless (member '%NoSelect flags) 1291 (unless (member '%NoSelect flags)
1324 (let* ((group (utf7-decode (if (stringp group) group 1292 (push (utf7-decode (if (stringp group)
1325 (format "%s" group)) t)) 1293 group
1326 (group (cond ((equal inbox group) 1294 (format "%s" group))
1327 group) 1295 t)
1328 ((string-prefix-p prefix group) 1296 groups))))
1329 (substring group prefix-len))
1330 (t
1331 (concat "#" group)))))
1332 (push group groups)))))
1333 (nreverse groups))) 1297 (nreverse groups)))
1334 1298
1335(defun nnimap-get-responses (sequences) 1299(defun nnimap-get-responses (sequences)
@@ -1355,7 +1319,7 @@ If LIMIT, first try to limit the search to the N last articles."
1355 (dolist (group groups) 1319 (dolist (group groups)
1356 (setf (nnimap-examined nnimap-object) group) 1320 (setf (nnimap-examined nnimap-object) group)
1357 (push (list (nnimap-send-command "EXAMINE %S" 1321 (push (list (nnimap-send-command "EXAMINE %S"
1358 (nnimap-group-to-imap group)) 1322 (utf7-encode group t))
1359 group) 1323 group)
1360 sequences)) 1324 sequences))
1361 (nnimap-wait-for-response (caar sequences)) 1325 (nnimap-wait-for-response (caar sequences))
@@ -1427,7 +1391,7 @@ If LIMIT, first try to limit the search to the N last articles."
1427 unexist) 1391 unexist)
1428 (push 1392 (push
1429 (list (nnimap-send-command "EXAMINE %S (%s (%s %s))" 1393 (list (nnimap-send-command "EXAMINE %S (%s (%s %s))"
1430 (nnimap-group-to-imap group) 1394 (utf7-encode group t)
1431 (nnimap-quirk "QRESYNC") 1395 (nnimap-quirk "QRESYNC")
1432 uidvalidity modseq) 1396 uidvalidity modseq)
1433 'qresync 1397 'qresync
@@ -1449,7 +1413,7 @@ If LIMIT, first try to limit the search to the N last articles."
1449 (cl-incf (nnimap-initial-resync nnimap-object)) 1413 (cl-incf (nnimap-initial-resync nnimap-object))
1450 (setq start 1)) 1414 (setq start 1))
1451 (push (list (nnimap-send-command "%s %S" command 1415 (push (list (nnimap-send-command "%s %S" command
1452 (nnimap-group-to-imap group)) 1416 (utf7-encode group t))
1453 (nnimap-send-command "UID FETCH %d:* FLAGS" start) 1417 (nnimap-send-command "UID FETCH %d:* FLAGS" start)
1454 start group command) 1418 start group command)
1455 sequences)))) 1419 sequences))))
@@ -1883,7 +1847,7 @@ Return the server's response to the SELECT or EXAMINE command."
1883 (if read-only 1847 (if read-only
1884 "EXAMINE" 1848 "EXAMINE"
1885 "SELECT") 1849 "SELECT")
1886 (nnimap-group-to-imap group)))) 1850 (utf7-encode group t))))
1887 (when (car result) 1851 (when (car result)
1888 (setf (nnimap-group nnimap-object) group 1852 (setf (nnimap-group nnimap-object) group
1889 (nnimap-select-result nnimap-object) result) 1853 (nnimap-select-result nnimap-object) result)
@@ -2141,7 +2105,7 @@ Return the server's response to the SELECT or EXAMINE command."
2141 (dolist (spec specs) 2105 (dolist (spec specs)
2142 (when (and (not (member (car spec) groups)) 2106 (when (and (not (member (car spec) groups))
2143 (not (eq (car spec) 'junk))) 2107 (not (eq (car spec) 'junk)))
2144 (nnimap-command "CREATE %S" (nnimap-group-to-imap (car spec))))) 2108 (nnimap-command "CREATE %S" (utf7-encode (car spec) t))))
2145 ;; Then copy over all the messages. 2109 ;; Then copy over all the messages.
2146 (erase-buffer) 2110 (erase-buffer)
2147 (dolist (spec specs) 2111 (dolist (spec specs)
@@ -2157,7 +2121,7 @@ Return the server's response to the SELECT or EXAMINE command."
2157 "UID MOVE %s %S" 2121 "UID MOVE %s %S"
2158 "UID COPY %s %S") 2122 "UID COPY %s %S")
2159 (nnimap-article-ranges ranges) 2123 (nnimap-article-ranges ranges)
2160 (nnimap-group-to-imap group)) 2124 (utf7-encode group t))
2161 ranges) 2125 ranges)
2162 sequences))))) 2126 sequences)))))
2163 ;; Wait for the last COPY response... 2127 ;; Wait for the last COPY response...