From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68348 Path: news.gmane.org!not-for-mail From: Daiki Ueno Newsgroups: gmane.emacs.gnus.general Subject: nnimap: IMAP mailbox name <-> Gnus newsgroup name Date: Sat, 07 Mar 2009 19:59:54 +0900 Message-ID: <87ljrh1tud.fsf@broken.deisui.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1236423690 7798 80.91.229.12 (7 Mar 2009 11:01:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Mar 2009 11:01:30 +0000 (UTC) To: Simon Josefsson , ding@gnus.org Original-X-From: ding-owner+M16787@lists.math.uh.edu Sat Mar 07 12:02:46 2009 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1LfuIl-00015D-RV for ding-account@gmane.org; Sat, 07 Mar 2009 12:02:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1LfuGH-000183-U6; Sat, 07 Mar 2009 05:00:10 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1LfuGF-00017n-RS for ding@lists.math.uh.edu; Sat, 07 Mar 2009 05:00:07 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1LfuGA-0000At-8K for ding@lists.math.uh.edu; Sat, 07 Mar 2009 05:00:07 -0600 Original-Received: from ti-out-0910.google.com ([209.85.142.187]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1LfuGV-00011R-00 for ; Sat, 07 Mar 2009 12:00:23 +0100 Original-Received: by ti-out-0910.google.com with SMTP id 28so462909tif.1 for ; Sat, 07 Mar 2009 02:59:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:user-agent:mime-version:content-type; bh=kRyW1iMDkNOEhzJKM5nJvfrBx8TOE/FE2+jlVV4lGKk=; b=MimKe1aStpgrftHMU02pkzW6ZKjpX9Pu75l3aGl00jSWR7jm5BioWxuuw+J2f7EZU7 ibfp5m9pPCWwX3ApQAQLCuKL5SLwxPj5UcLUhKFMUt6yHJGXX77iYW6XvZWVZfIzuP+0 8C1s+al5qGnYLyhYL/m7n5pdELCd3GtjkEGCA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:user-agent:mime-version :content-type; b=hJY5QokZmEWbi0ZnEnqAS+6P47ZqnHgUTGabCoXP4eB5GWVjMwpkRNcB0+img6p6Hl vFNJLGnxmqW14LbpjROo0aPobU1mEjYusDjqenBakj1A9Fq7gvqKQT2g3nyEgkenTqdX bqz/yeftrLvqolfb5zZkjBb+qPKNpTgEstdxo= Original-Received: by 10.110.31.5 with SMTP id e5mr5284167tie.35.1236423597938; Sat, 07 Mar 2009 02:59:57 -0800 (PST) Original-Received: from broken (g187018.scn-net.ne.jp [202.83.187.18]) by mx.google.com with ESMTPS id j5sm252732tid.1.2009.03.07.02.59.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 07 Mar 2009 02:59:56 -0800 (PST) User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:68348 Archived-At: --=-=-= Hi Simon, Presumably nnimap has a confusion of encodings used for IMAP mailbox names and Gnus group names. The attached is a patch which converts the Gnus group name to the IMAP mailbox name, and back. With this change, I have confirmed that localized Gmail folder names are properly decoded/encoded. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=nnimap-convert-mailbox-name.diff Index: lisp/nnimap.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/nnimap.el,v retrieving revision 7.59 diff -u -r7.59 nnimap.el --- lisp/nnimap.el 26 Jan 2009 15:23:27 -0000 7.59 +++ lisp/nnimap.el 7 Mar 2009 10:58:58 -0000 @@ -559,8 +559,8 @@ "Find lowest and highest active article number in GROUP. If EXAMINE is non-nil the group is selected read-only." (with-current-buffer nnimap-server-buffer - (when (or (string= group (imap-current-mailbox)) - (imap-mailbox-select group examine)) + (when (or (string= group (nnimap-mailbox-to-group (imap-current-mailbox))) + (imap-mailbox-select (nnimap-group-to-mailbox group) examine)) (let (minuid maxuid) (when (> (imap-mailbox-get 'exists) 0) (imap-fetch-safe '("1,*" . "1,*:*") "UID" nil 'nouidfetch) @@ -574,12 +574,14 @@ "Make GROUP the current group, and SERVER the current server." (when (nnimap-possibly-change-server server) (with-current-buffer nnimap-server-buffer - (if (or (null group) (imap-current-mailbox-p group)) - imap-current-mailbox - (if (imap-mailbox-select group) + (if (or (null group) (imap-current-mailbox-p + (nnimap-group-to-mailbox group))) + (nnimap-mailbox-to-group imap-current-mailbox) + (if (imap-mailbox-select (nnimap-group-to-mailbox group)) (if (or (nnimap-verify-uidvalidity group (or server nnimap-current-server)) - (zerop (imap-mailbox-get 'exists group)) + (zerop (imap-mailbox-get 'exists + (nnimap-group-to-mailbox group))) t ;; for OGnus to see if ignoring uidvalidity ;; changes has any bad effects. (yes-or-no-p @@ -597,6 +599,21 @@ (setq string (replace-match " " t t string))) string)) +;; For a historical reason (perhaps it has to do with +;; draft-ietf-usefor-article-format-06.txt?) Gnus uses multibytified +;; UTF-8 as the representation of internal group names. We need to +;; first make it unibyte, then reconstruct the original mailbox name +;; before calling imap.el functions. +(defun nnimap-group-to-mailbox (group) + "Return the mailbox name corresponding to GROUP." + (if group + (mm-string-as-multibyte (string-to-unibyte group)))) + +(defun nnimap-mailbox-to-group (mailbox) + "Return the group name corresponding to MAILBOX." + (if mailbox + (mm-string-to-multibyte (mm-string-as-unibyte mailbox)))) + ;; Required backend functions (defun nnimap-retrieve-headers-progress () @@ -1035,7 +1052,8 @@ (let ((old (gnus-gethash-safe (gnus-group-prefixed-name group server) nnimap-mailbox-info))) (list (nth 0 old) (nth 1 old) - (imap-mailbox-status group 'unseen nnimap-server-buffer) + (imap-mailbox-status (nnimap-group-to-mailbox group) 'unseen + nnimap-server-buffer) (nth 3 old))) nnimap-mailbox-info)) @@ -1145,7 +1163,8 @@ 'asyncgroups 'slowgroups) (list group (imap-mailbox-status-asynch - group '(uidvalidity uidnext unseen) + (nnimap-group-to-mailbox group) + '(uidvalidity uidnext unseen) nnimap-server-buffer)))) (dolist (asyncgroup asyncgroups) (let ((group (nth 0 asyncgroup)) @@ -1156,13 +1175,15 @@ (nth 0 (gnus-gethash (gnus-group-prefixed-name group server) nnimap-mailbox-info)) - (imap-mailbox-get 'uidvalidity group + (imap-mailbox-get 'uidvalidity + (nnimap-group-to-mailbox group) nnimap-server-buffer))) (not (string= (nth 1 (gnus-gethash (gnus-group-prefixed-name group server) nnimap-mailbox-info)) - (imap-mailbox-get 'uidnext group + (imap-mailbox-get 'uidnext + (nnimap-group-to-mailbox group) nnimap-server-buffer)))) (push (list group) slowgroups) (insert (nth 3 (gnus-gethash (gnus-group-prefixed-name @@ -1172,14 +1193,18 @@ (if nnimap-retrieve-groups-asynchronous (setq group (car group))) (gnus-message 7 "nnimap: Mailbox %s modified" group) - (imap-mailbox-put 'uidnext nil group nnimap-server-buffer) - (or (member "\\NoSelect" (imap-mailbox-get 'list-flags group - nnimap-server-buffer)) + (imap-mailbox-put 'uidnext nil (nnimap-group-to-mailbox group) + nnimap-server-buffer) + (or (member "\\NoSelect" (imap-mailbox-get + 'list-flags + (nnimap-group-to-mailbox group) + nnimap-server-buffer)) (let* ((info (nnimap-find-minmax-uid group 'examine)) (str (format "\"%s\" %d %d y\n" group (or (nth 2 info) 0) (max 1 (or (nth 1 info) 1))))) - (when (> (or (imap-mailbox-get 'recent group + (when (> (or (imap-mailbox-get 'recent + (nnimap-group-to-mailbox group) nnimap-server-buffer) 0) 0) (push (list (cons group 0)) nnmail-split-history)) @@ -1188,17 +1213,23 @@ (gnus-sethash (gnus-group-prefixed-name group server) (list (or (imap-mailbox-get - 'uidvalidity group nnimap-server-buffer) + 'uidvalidity (nnimap-group-to-mailbox group) + nnimap-server-buffer) (imap-mailbox-status - group 'uidvalidity nnimap-server-buffer)) + (nnimap-group-to-mailbox group) 'uidvalidity + nnimap-server-buffer)) (or (imap-mailbox-get - 'uidnext group nnimap-server-buffer) + 'uidnext (nnimap-group-to-mailbox group) + nnimap-server-buffer) (imap-mailbox-status - group 'uidnext nnimap-server-buffer)) + (nnimap-group-to-mailbox group) 'uidnext + nnimap-server-buffer)) (or (imap-mailbox-get - 'unseen group nnimap-server-buffer) + 'unseen (nnimap-group-to-mailbox group) + nnimap-server-buffer) (imap-mailbox-status - group 'unseen nnimap-server-buffer)) + (nnimap-group-to-mailbox group) 'unseen + nnimap-server-buffer)) str) nnimap-mailbox-info))))))) (gnus-message 5 "nnimap: Checking mailboxes...done") @@ -1268,7 +1299,8 @@ (when (nnimap-possibly-change-group group server) (with-current-buffer nnimap-server-buffer (let (action) - (gnus-message 7 "nnimap: Setting marks in %s..." group) + (gnus-message 7 "nnimap: Setting marks in %s..." + (nnimap-group-to-mailbox group)) (while (setq action (pop actions)) (let ((range (nth 0 action)) (what (nth 1 action)) @@ -1309,7 +1341,8 @@ (imap-message-flags-set (imap-range-to-message-set range) (nnimap-mark-to-flag marks nil t))))))) - (gnus-message 7 "nnimap: Setting marks in %s...done" group)))) + (gnus-message 7 "nnimap: Setting marks in %s...done" + (nnimap-group-to-mailbox group))))) nil) (defun nnimap-split-fancy () @@ -1396,7 +1429,8 @@ article) (setq removeorig t)) ((imap-message-copy (number-to-string article) - to-group nil 'nocopyuid) + (nnimap-group-to-mailbox to-group) + nil 'nocopyuid) (message "IMAP split moved %s:%s:%d to %s" server inbox article to-group) (setq removeorig t) @@ -1460,8 +1494,10 @@ (deffoo nnimap-request-create-group (group &optional server args) (when (nnimap-possibly-change-server server) - (or (imap-mailbox-status group 'uidvalidity nnimap-server-buffer) - (imap-mailbox-create group nnimap-server-buffer) + (or (imap-mailbox-status (nnimap-group-to-mailbox group) 'uidvalidity + nnimap-server-buffer) + (imap-mailbox-create (nnimap-group-to-mailbox group) + nnimap-server-buffer) (nnheader-report 'nnimap "%S" (imap-error-text nnimap-server-buffer))))) @@ -1594,7 +1630,8 @@ nnimap-current-move-group) (imap-message-copy (number-to-string nnimap-current-move-article) - group 'dontcreate nil + (nnimap-group-to-mailbox group) + 'dontcreate nil nnimap-server-buffer)) (with-current-buffer (current-buffer) (goto-char (point-min)) @@ -1614,28 +1651,33 @@ ;; this 'or' is for Cyrus server bug (or (null (imap-current-mailbox nnimap-server-buffer)) (imap-mailbox-unselect nnimap-server-buffer)) - (imap-message-append group (current-buffer) nil nil + (imap-message-append (nnimap-grou-to-mailbox group) + (current-buffer) nil nil nnimap-server-buffer))) (cons group (nth 1 uid)) (nnheader-report 'nnimap (imap-error-text nnimap-server-buffer)))))) (deffoo nnimap-request-delete-group (group force &optional server) (when (nnimap-possibly-change-server server) - (when (string= group (imap-current-mailbox nnimap-server-buffer)) + (when (string= (nnimap-group-to-mailbox group) + (imap-current-mailbox nnimap-server-buffer)) (imap-mailbox-unselect nnimap-server-buffer)) (with-current-buffer nnimap-server-buffer (if force - (or (null (imap-mailbox-status group 'uidvalidity)) - (imap-mailbox-delete group)) + (or (null (imap-mailbox-status (nnimap-group-to-mailbox group) + 'uidvalidity)) + (imap-mailbox-delete (nnimap-group-to-mailbox group))) ;; UNSUBSCRIBE? t)))) (deffoo nnimap-request-rename-group (group new-name &optional server) (when (nnimap-possibly-change-server server) - (imap-mailbox-rename group new-name nnimap-server-buffer))) + (imap-mailbox-rename (nnimap-group-to-mailbox group) + (nnimap-group-to-mailbox new-name) + nnimap-server-buffer))) (defun nnimap-expunge (mailbox server) - (when (nnimap-possibly-change-group mailbox server) + (when (nnimap-possibly-change-group (nnimap-group-to-mailbox mailbox) server) (imap-mailbox-expunge nil nnimap-server-buffer))) (defun nnimap-acl-get (mailbox server) --=-=-= Regards, -- Daiki Ueno --=-=-=--