This commit was manufactured by cvs2svn to create branch 'elmo-imap4-new-
[elisp/wanderlust.git] / elmo / elmo-imap4.el
index d64894d..58c0546 100644 (file)
@@ -181,7 +181,7 @@ REGEXP should have a grouping for namespace prefix.")
 
 (defconst elmo-imap4-folder-name-syntax
   `(mailbox
-    (?: [user "^[A-Za-z]"] (?/ [auth ".+"]))
+    (?: [user "^[A-Za-z0-9]"] (?/ [auth ".+"]))
     ,@elmo-net-folder-name-syntax))
 
 ;; For debugging.
@@ -738,6 +738,17 @@ Returns response value if selecting folder succeed. "
                         (format "Select %s failed" mailbox)))))))
       (and result response))))
 
+(defun elmo-imap4-session-unselect-mailbox (session mailbox)
+  "Unselect MAILBOX in SESSION.
+Deselecting will exit selected state without causing silent
+EXPUNGE for deleted messages."
+  (if (elmo-imap4-session-capable-p session 'unselect)
+      (elmo-imap4-send-command-wait session "unselect")
+    (elmo-imap4-send-command-wait
+     session
+     (list "examine " (elmo-imap4-mailbox mailbox)))
+    (elmo-imap4-send-command-wait session "close")))
+
 (defun elmo-imap4-check-validity (spec validity-file)
 ;;; Not used.
 ;;;(elmo-imap4-send-command-wait
@@ -939,12 +950,6 @@ If CHOP-LENGTH is not specified, message set is not chopped."
               (and (elmo-file-cache-exists-p msg-id)
                    '(cached)))
            saved-flags))
-    (when (and (or (memq 'important flag-list)
-                  (memq 'answered flag-list))
-              (memq 'unread flag-list))
-      (setq elmo-imap4-seen-messages
-           (cons (elmo-message-entity-number entity)
-                 elmo-imap4-seen-messages)))
     (elmo-msgdb-append-entity elmo-imap4-current-msgdb
                              entity
                              flag-list)))
@@ -1154,15 +1159,15 @@ If CHOP-LENGTH is not specified, message set is not chopped."
                       (if (sasl-step-data step)
                           (elmo-base64-encode-string (sasl-step-data step)
                                                      'no-line-break)
-                        "")))))))
+                        ""))))))))
 ;; Some servers return reduced capabilities when client asks for them
 ;; before login. It might be a good idea to ask them again, otherwise
 ;; we can miss some useful feature.
-        (elmo-imap4-session-set-capability-internal
-         session
-         (elmo-imap4-response-value
-          (elmo-imap4-send-command-wait session "capability")
-          'capability)))))))
+       (elmo-imap4-session-set-capability-internal
+        session
+        (elmo-imap4-response-value
+         (elmo-imap4-send-command-wait session "capability")
+         'capability))))))
 
 (luna-define-method elmo-network-setup-session ((session
                                                 elmo-imap4-session))
@@ -1314,7 +1319,7 @@ Return nil if no complete line has arrived."
       (while (setq end (elmo-imap4-find-next-line))
        (save-restriction
          (narrow-to-region (point-min) end)
-         (delete-backward-char (length elmo-imap4-server-eol))
+         (delete-char (- (length elmo-imap4-server-eol)))
          (goto-char (point-min))
          (unwind-protect
              (case elmo-imap4-status
@@ -1455,7 +1460,7 @@ Return nil if no complete line has arrived."
                                      ")"))))
           (ESEARCH     (list
                         'esearch
-                        (cddr (split-string (buffer-substring (point) (point-max)) " " "\,"))))
+                        (cddr (split-string (buffer-substring (point) (point-max)) " "))))
           (STATUS     (elmo-imap4-parse-status))
           ;; Added
           (NAMESPACE  (elmo-imap4-parse-namespace))
@@ -1663,7 +1668,7 @@ Return nil if no complete line has arrived."
                           (goto-char (match-end 1)))))
                   (UNSEEN
                    (list 'unseen (read (current-buffer))))
-                  (t 
+                  (t
                    (message
                     "Unknown status data %s in mailbox %s ignored"
                     token mailbox))))
@@ -1990,16 +1995,14 @@ Return nil if no complete line has arrived."
   (elmo-imap4-list
    folder
    (concat
-    (let ((killed
-          (elmo-folder-killed-list-internal
-           folder)))
+    (let ((killed (elmo-folder-killed-list-internal folder)))
       (if (and killed
-              (eq (length killed) 1)
-              (consp (car killed))
-              (eq (car (car killed)) 1))
-;; What about elmo-imap4-use-uid?
-         (format "uid %d:%s" (cdr (car killed)) max)
-       (format "uid %s:%s" min max)))
+              (eq (length killed) 1)
+              (consp (car killed))
+              (eq (car (car killed)) 1))
+         ;; What about elmo-imap4-use-uid?
+         (format "uid %d:%s" (cdr (car killed)) max)
+       (format "uid %s:%s" min max)))
     " undeleted")))
 
 (luna-define-method elmo-folder-list-messages-plugged
@@ -2180,6 +2183,9 @@ Return nil if no complete line has arrived."
     (elmo-imap4-session-select-mailbox session
                                       (elmo-imap4-folder-mailbox-internal
                                        folder))
+    (elmo-imap4-session-unselect-mailbox session
+                                        (elmo-imap4-folder-mailbox-internal
+                                         folder))
     (elmo-imap4-send-command-wait session "close")
     (elmo-imap4-send-command-wait
      session