(imap-calculate-literal-size-first): New variable.
authorSimon Josefsson <jas@extundo.com>
Sun, 16 Jul 2000 22:41:55 +0000 (22:41 +0000)
committerSimon Josefsson <jas@extundo.com>
Sun, 16 Jul 2000 22:41:55 +0000 (22:41 +0000)
(imap-local-variables): Add it.
(imap-kerberos4-open): Set it.
(imap-send-command): Use it.

lisp/ChangeLog
lisp/imap.el

index 76f8628..f2babd9 100644 (file)
@@ -1,3 +1,10 @@
+2000-07-19  Kim-Minh Kaplan <kmkaplan@galaxy.fr>
+
+       * imap.el (imap-calculate-literal-size-first): New variable.
+       (imap-local-variables): Add it.
+       (imap-kerberos4-open): Set it.
+       (imap-send-command): Use it.
+
 2000-07-17 14:18:16  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * mailcap.el (mailcap-mimetypes-parsed-p): New variable.
index cdc2d3d..88fe381 100644 (file)
@@ -291,6 +291,7 @@ encoded mailboxes which doesn't translate into ISO-8859-1.")
                                 imap-failed-tags
                                 imap-tag
                                 imap-process
+                                imap-calculate-literal-size-first
                                 imap-mailbox-data))
 
 ;; Internal variables.
@@ -301,6 +302,7 @@ encoded mailboxes which doesn't translate into ISO-8859-1.")
 (defvar imap-port nil)
 (defvar imap-username nil)
 (defvar imap-password nil)
+(defvar imap-calculate-literal-size-first nil)
 (defvar imap-state 'closed 
   "IMAP state.
 Valid states are `closed', `initial', `nonauth', `auth', `selected'
@@ -445,7 +447,8 @@ If ARGS, PROMPT is used as an argument to `format'."
             response)
        (when process
          (with-current-buffer buffer
-           (setq imap-client-eol "\n")
+           (setq imap-client-eol "\n"
+                 imap-calculate-literal-size-first t)
            (while (and (memq (process-status process) '(open run))
                        (goto-char (point-min))
                         ;; cyrus 1.6.x (13? < x <= 22) queries capabilities
@@ -1485,9 +1488,21 @@ on failure."
        (cond ((stringp cmd)
               (setq cmdstr (concat cmdstr cmd)))
              ((bufferp cmd)
-              (setq cmdstr 
-                    (concat cmdstr (format "{%d}" (with-current-buffer cmd
-                                                    (buffer-size)))))
+              (let ((eol imap-client-eol)
+                    (calcfirst imap-calculate-literal-size-first)
+                    size)
+                (with-current-buffer cmd
+                  (if calcfirst
+                      (setq size (buffer-size)))
+                  (when (not (equal eol "\r\n"))
+                    ;; XXX modifies buffer!
+                    (goto-char (point-min))
+                    (while (search-forward "\r\n" nil t)
+                      (replace-match eol)))
+                  (if (not calcfirst)
+                      (setq size (buffer-size))))
+                (setq cmdstr 
+                      (concat cmdstr (format "{%d}" size))))
               (unwind-protect
                   (progn
                     (imap-send-command-1 cmdstr)
@@ -1498,11 +1513,6 @@ on failure."
                             (stream imap-stream)
                             (eol imap-client-eol))
                         (with-current-buffer cmd
-                          (when (not (equal eol "\r\n"))
-                            ;; XXX modifies buffer!
-                            (goto-char (point-min))
-                            (while (search-forward "\r\n" nil t)
-                              (replace-match eol)))
                           (and imap-log
                                (with-current-buffer (get-buffer-create
                                                      imap-log)