From 40fa6ff0052818fd778f4f88eb46213ee9629732 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Thu, 31 May 2018 12:13:28 +0100 Subject: [PATCH 3/3] Turn nnimap-namespaces into a defvoo to make it per-server. --- lisp/gnus/nnimap.el | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 7ad54a..3c95f1 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -117,14 +117,14 @@ nnimap-connection-alist (defvoo nnimap-current-infos nil) +(defvoo nnimap-namespace nil) + (defun nnimap-decode-gnus-group (group) (decode-coding-string group 'utf-8)) (defun nnimap-encode-gnus-group (group) (encode-coding-string group 'utf-8)) -(setq nnimap-namespaces nil) - (defvoo nnimap-fetch-partial-articles nil "If non-nil, Gnus will fetch partial articles. If t, Gnus will fetch only the first part. If a string, it @@ -177,17 +177,15 @@ nnimap-inhibit-logging (defun nnimap-group-to-imap (group) "Convert Gnus group name to IMAP mailbox name." - (let* ((prefix (cadr (assoc (nnoo-current-server 'nnimap) - nnimap-namespaces))) - (inbox (substring prefix 0 -1))) + (let* ((inbox (substring nnimap-namespace 0 -1))) (utf7-encode - (cond ((or (not prefix) + (cond ((or (not nnimap-namespace) (string-equal group inbox)) group) ((string-prefix-p "#" group) (substring group 1)) (t - (concat prefix group))) t))) + (concat nnimap-namespace group))) t))) (defun nnimap-buffer () (nnimap-find-process-buffer nntp-server-buffer)) @@ -526,13 +524,8 @@ nnimap-open-connection-1 (when (string-match "^\\*\\W+NAMESPACE\\W+((\"\\([^\"\n]+\\)\"\\W+\"\\(.\\)\"))\\W+" response) - (let ((namespace (cons (match-string 1 response) - (match-string 2 response))) - (entry (assoc server nnimap-namespaces))) - (if entry - (setcdr entry namespace) - (push (cons server namespace) nnimap-namespaces))))))) - ;; If the login failed, then forget the credentials + (setq nnimap-namespace (match-string 1 response)))))) + ;; If the login failed, then forget the credentials ;; that are now possibly cached. (dolist (host (list (nnoo-current-server 'nnimap) nnimap-address)) @@ -1305,8 +1298,7 @@ nnimap-add-cr (defun nnimap-get-groups () (erase-buffer) (let* ((sequence (nnimap-send-command "LIST \"\" \"*\"")) - (prefix (cadr (assoc (nnoo-current-server 'nnimap) - nnimap-namespaces))) + (prefix nnimap-namespace) (prefix-len (length prefix)) (inbox (substring prefix 0 -1)) groups) -- 2.11.0