Revert "Make nnimap support IMAP namespaces"

This reverts commit 7b5b3ddb2d.

Insufficiently tested before committing -- bugs out several places
when not using namespaces.
This commit is contained in:
Lars Ingebrigtsen
2018-07-23 09:01:24 +02:00
parent 8f3bca3ad5
commit 216b9b2dbf
3 changed files with 27 additions and 74 deletions

View File

@@ -14320,12 +14320,6 @@ fetch all textual parts, while leaving the rest on the server.
If non-@code{nil}, record all @acronym{IMAP} commands in the
@samp{"*imap log*"} buffer.
@item nnimap-use-namespaces
If non-@code{nil}, omit the IMAP namespace prefix in nnimap group
names. If your IMAP mailboxes are called something like @samp{INBOX}
and @samp{INBOX.Lists.emacs}, but you'd like the nnimap group names to
be @samp{INBOX} and @samp{Lists.emacs}, you should enable this option.
@end table

View File

@@ -46,11 +46,6 @@ option --enable-check-lisp-object-type is therefore no longer as
useful and so is no longer enabled by default in developer builds,
to reduce differences between developer and production builds.
** Gnus
+++
*** The nnimap backend now has support for IMAP namespaces.
* Startup Changes in Emacs 27.1

View File

@@ -55,13 +55,6 @@
If nnimap-stream is `ssl', this will default to `imaps'. If not,
it will default to `imap'.")
(defvoo nnimap-use-namespaces nil
"Whether to use IMAP namespaces.
If in Gnus your folder names in all start with (e.g.) `INBOX',
you probably want to set this to t. The effects of this are
purely cosmetical, but changing this variable will affect the
names of your nnimap groups. ")
(defvoo nnimap-stream 'undecided
"How nnimap talks to the IMAP server.
The value should be either `undecided', `ssl' or `tls',
@@ -117,8 +110,6 @@ some servers.")
(defvoo nnimap-current-infos nil)
(defvoo nnimap-namespace nil)
(defun nnimap-decode-gnus-group (group)
(decode-coding-string group 'utf-8))
@@ -175,18 +166,6 @@ textual parts.")
(defvar nnimap-inhibit-logging nil)
(defun nnimap-group-to-imap (group)
"Convert Gnus group name to IMAP mailbox name."
(let* ((inbox (substring nnimap-namespace 0 -1)))
(utf7-encode
(cond ((or (not nnimap-namespace)
(string-equal group inbox))
group)
((string-prefix-p "#" group)
(substring group 1))
(t
(concat nnimap-namespace group))) t)))
(defun nnimap-buffer ()
(nnimap-find-process-buffer nntp-server-buffer))
@@ -463,8 +442,7 @@ textual parts.")
(props (cdr stream-list))
(greeting (plist-get props :greeting))
(capabilities (plist-get props :capabilities))
(stream-type (plist-get props :type))
(server (nnoo-current-server 'nnimap)))
(stream-type (plist-get props :type)))
(when (and stream (not (memq (process-status stream) '(open run))))
(setq stream nil))
@@ -497,7 +475,9 @@ textual parts.")
;; the virtual server name and the address
(nnimap-credentials
(gnus-delete-duplicates
(list server nnimap-address))
(list
(nnoo-current-server 'nnimap)
nnimap-address))
ports
nnimap-user))))
(setq nnimap-object nil)
@@ -516,17 +496,8 @@ textual parts.")
(dolist (response (cddr (nnimap-command "CAPABILITY")))
(when (string= "CAPABILITY" (upcase (car response)))
(setf (nnimap-capabilities nnimap-object)
(mapcar #'upcase (cdr response)))))
(when (and nnimap-use-namespaces
(nnimap-capability "NAMESPACE"))
(erase-buffer)
(nnimap-wait-for-response (nnimap-send-command "NAMESPACE"))
(let ((response (nnimap-last-response-string)))
(when (string-match
"^\\*\\W+NAMESPACE\\W+((\"\\([^\"\n]+\\)\"\\W+\"\\(.\\)\"))\\W+"
response)
(setq nnimap-namespace (match-string 1 response))))))
;; If the login failed, then forget the credentials
(mapcar #'upcase (cdr response))))))
;; If the login failed, then forget the credentials
;; that are now possibly cached.
(dolist (host (list (nnoo-current-server 'nnimap)
nnimap-address))
@@ -866,7 +837,7 @@ textual parts.")
(with-current-buffer (nnimap-buffer)
(erase-buffer)
(let ((group-sequence
(nnimap-send-command "SELECT %S" (nnimap-group-to-imap group)))
(nnimap-send-command "SELECT %S" (utf7-encode group t)))
(flag-sequence
(nnimap-send-command "UID FETCH 1:* FLAGS")))
(setf (nnimap-group nnimap-object) group)
@@ -899,13 +870,13 @@ textual parts.")
(setq group (nnimap-decode-gnus-group group))
(when (nnimap-change-group nil server)
(with-current-buffer (nnimap-buffer)
(car (nnimap-command "CREATE %S" (nnimap-group-to-imap group))))))
(car (nnimap-command "CREATE %S" (utf7-encode group t))))))
(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" (nnimap-group-to-imap group))))))
(car (nnimap-command "DELETE %S" (utf7-encode group t))))))
(deffoo nnimap-request-rename-group (group new-name &optional server)
(setq group (nnimap-decode-gnus-group group))
@@ -913,7 +884,7 @@ textual parts.")
(with-current-buffer (nnimap-buffer)
(nnimap-unselect-group)
(car (nnimap-command "RENAME %S %S"
(nnimap-group-to-imap group) (nnimap-group-to-imap new-name))))))
(utf7-encode group t) (utf7-encode new-name t))))))
(defun nnimap-unselect-group ()
;; Make sure we don't have this group open read/write by asking
@@ -973,7 +944,7 @@ textual parts.")
"UID COPY %d %S"))
(result (nnimap-command
command article
(nnimap-group-to-imap internal-move-group))))
(utf7-encode internal-move-group t))))
(when (and (car result) (not can-move))
(nnimap-delete-article article))
(cons internal-move-group
@@ -1040,7 +1011,7 @@ textual parts.")
"UID MOVE %s %S"
"UID COPY %s %S")
(nnimap-article-ranges (gnus-compress-sequence articles))
(nnimap-group-to-imap (gnus-group-real-name nnmail-expiry-target)))
(utf7-encode (gnus-group-real-name nnmail-expiry-target) t))
(set (if can-move 'deleted-articles 'articles-to-delete) articles))))
t)
(t
@@ -1165,7 +1136,7 @@ If LIMIT, first try to limit the search to the N last articles."
(unsubscribe "UNSUBSCRIBE")))))
(when command
(with-current-buffer (nnimap-buffer)
(nnimap-command "%s %S" (cadr command) (nnimap-group-to-imap group)))))))
(nnimap-command "%s %S" (cadr command) (utf7-encode group t)))))))
(deffoo nnimap-request-set-mark (group actions &optional server)
(setq group (nnimap-decode-gnus-group group))
@@ -1220,7 +1191,7 @@ If LIMIT, first try to limit the search to the N last articles."
(nnimap-unselect-group))
(erase-buffer)
(setq sequence (nnimap-send-command
"APPEND %S {%d}" (nnimap-group-to-imap group)
"APPEND %S {%d}" (utf7-encode group t)
(length message)))
(unless nnimap-streaming
(nnimap-wait-for-connection "^[+]"))
@@ -1300,11 +1271,8 @@ If LIMIT, first try to limit the search to the N last articles."
(defun nnimap-get-groups ()
(erase-buffer)
(let* ((sequence (nnimap-send-command "LIST \"\" \"*\""))
(prefix nnimap-namespace)
(prefix-len (length prefix))
(inbox (substring prefix 0 -1))
groups)
(let ((sequence (nnimap-send-command "LIST \"\" \"*\""))
groups)
(nnimap-wait-for-response sequence)
(subst-char-in-region (point-min) (point-max)
?\\ ?% t)
@@ -1321,15 +1289,11 @@ If LIMIT, first try to limit the search to the N last articles."
(skip-chars-backward " \r\"")
(point)))))
(unless (member '%NoSelect flags)
(let* ((group (utf7-decode (if (stringp group) group
(format "%s" group)) t))
(group (cond ((equal inbox group)
group)
((string-prefix-p prefix group)
(substring group prefix-len))
(t
(concat "#" group)))))
(push group groups)))))
(push (utf7-decode (if (stringp group)
group
(format "%s" group))
t)
groups))))
(nreverse groups)))
(defun nnimap-get-responses (sequences)
@@ -1355,7 +1319,7 @@ If LIMIT, first try to limit the search to the N last articles."
(dolist (group groups)
(setf (nnimap-examined nnimap-object) group)
(push (list (nnimap-send-command "EXAMINE %S"
(nnimap-group-to-imap group))
(utf7-encode group t))
group)
sequences))
(nnimap-wait-for-response (caar sequences))
@@ -1427,7 +1391,7 @@ If LIMIT, first try to limit the search to the N last articles."
unexist)
(push
(list (nnimap-send-command "EXAMINE %S (%s (%s %s))"
(nnimap-group-to-imap group)
(utf7-encode group t)
(nnimap-quirk "QRESYNC")
uidvalidity modseq)
'qresync
@@ -1449,7 +1413,7 @@ If LIMIT, first try to limit the search to the N last articles."
(cl-incf (nnimap-initial-resync nnimap-object))
(setq start 1))
(push (list (nnimap-send-command "%s %S" command
(nnimap-group-to-imap group))
(utf7-encode group t))
(nnimap-send-command "UID FETCH %d:* FLAGS" start)
start group command)
sequences))))
@@ -1883,7 +1847,7 @@ Return the server's response to the SELECT or EXAMINE command."
(if read-only
"EXAMINE"
"SELECT")
(nnimap-group-to-imap group))))
(utf7-encode group t))))
(when (car result)
(setf (nnimap-group nnimap-object) group
(nnimap-select-result nnimap-object) result)
@@ -2141,7 +2105,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" (nnimap-group-to-imap (car spec)))))
(nnimap-command "CREATE %S" (utf7-encode (car spec) t))))
;; Then copy over all the messages.
(erase-buffer)
(dolist (spec specs)
@@ -2157,7 +2121,7 @@ Return the server's response to the SELECT or EXAMINE command."
"UID MOVE %s %S"
"UID COPY %s %S")
(nnimap-article-ranges ranges)
(nnimap-group-to-imap group))
(utf7-encode group t))
ranges)
sequences)))))
;; Wait for the last COPY response...