From: Daiki Ueno <ueno@unixuser.org>
To: Simon Josefsson <jas@extundo.com>, ding@gnus.org
Subject: nnimap: IMAP mailbox name <-> Gnus newsgroup name
Date: Sat, 07 Mar 2009 19:59:54 +0900 [thread overview]
Message-ID: <87ljrh1tud.fsf@broken.deisui.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap-convert-mailbox-name.diff --]
[-- Type: text/x-diff, Size: 9724 bytes --]
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)
[-- Attachment #3: Type: text/plain, Size: 25 bytes --]
Regards,
--
Daiki Ueno
next reply other threads:[~2009-03-07 10:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-07 10:59 Daiki Ueno [this message]
2009-03-08 2:31 ` Daiki Ueno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ljrh1tud.fsf@broken.deisui.org \
--to=ueno@unixuser.org \
--cc=ding@gnus.org \
--cc=jas@extundo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).