* wl.el (wl-check-environment): Don't check wl-draft-folder is file.
authorteranisi <teranisi>
Wed, 15 Oct 2003 12:34:33 +0000 (12:34 +0000)
committerteranisi <teranisi>
Wed, 15 Oct 2003 12:34:33 +0000 (12:34 +0000)
* wl-vars.el (wl-folder-sync-range-alist): Changed default value.

* wl-util.el (wl-require-update-all-folder-p): New function.
(wl-get-assoc-list-value): Added `function' to match directive.
(wl-collect-draft): Rewrite.

* wl-summary.el (wl-summary-sync-update): Clear faces
when both wl-summary-lazy-highlight and wl-summary-lazy-update-mark
are non-nil.
(wl-summary-get-sync-range): Call wl-get-assoc-list-value with match
argument as function.
(wl-summary-input-range): Ditto.

* wl-folder.el (wl-draft-get-folder): New function.
(wl-folder-get-elmo-folder): Consider draft folder.

* wl-draft.el (wl-draft-buf-name, wl-draft-buffer-file-name): Abolish.
(wl-draft-buffer-message-number): New buffer local variable.
(wl-draft-folder-internal): New internal variable.
(wl-draft-delete): Rewrite.
(wl-draft-save): Ditto.
(wl-draft-create-buffer): Use wl-draft-get-folder instead of
wl-folder-get-elmo-folder.
(wl-draft-config-info-operation): Ditto.
(wl-jump-to-draft-folder): Ditto.
(wl-draft-prepare-edit): Set up auto-save-file-name-transforms.
(wl-draft-reedit): Rewrite.

* im-wl.el (wl-draft-send-with-imput-async): Follow the changes
in draft (Not tested).

* elmo.el (elmo-folder-next-message-number): New API.
(elmo-folder-next-message-number): Define.
(elmo-message-field): Don't check folder length.

* elmo-net.el (elmo-folder-next-message-number): Define.
(elmo-folder-next-message-number-unplugged): Define.

* elmo-map.el (elmo-folder-next-message-number): Define.
(elmo-folder-delete-messages): Clear hash value.

* elmo-imap4.el (elmo-folder-next-message-number-plugged): Define.

* elmo-dop.el (elmo-folder-next-message-number-dop): New function.
(elmo-folder-delete-messages-dop-delayed): Always return t.

15 files changed:
elmo/ChangeLog
elmo/elmo-dop.el
elmo/elmo-imap4.el
elmo/elmo-map.el
elmo/elmo-net.el
elmo/elmo.el
utils/ChangeLog
utils/im-wl.el
wl/ChangeLog
wl/wl-draft.el
wl/wl-folder.el
wl/wl-summary.el
wl/wl-util.el
wl/wl-vars.el
wl/wl.el

index 7f4f42d..ccb801f 100644 (file)
@@ -1,5 +1,20 @@
 2003-10-15  Yuuichi Teranishi  <teranisi@gohome.org>
 
+       * elmo.el (elmo-folder-next-message-number): New API.
+       (elmo-folder-next-message-number): Define.
+       (elmo-message-field): Don't check folder length.
+
+       * elmo-net.el (elmo-folder-next-message-number): Define.
+       (elmo-folder-next-message-number-unplugged): Define.
+
+       * elmo-map.el (elmo-folder-next-message-number): Define.
+       (elmo-folder-delete-messages): Clear hash value.
+
+       * elmo-imap4.el (elmo-folder-next-message-number-plugged): Define.
+
+       * elmo-dop.el (elmo-folder-next-message-number-dop): New function.
+       (elmo-folder-delete-messages-dop-delayed): Always return t.
+
        * elmo-version.el (elmo-version): Up to 2.11.19.
 
 2003-10-15  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
index 9094a6d..9309c16 100644 (file)
@@ -296,6 +296,17 @@ FOLDER is the folder structure."
     (setq max-num (or (car number-list) 0))
     (cons (+ max-num spool-length) (+ (length number-list) spool-length))))
 
+(defun elmo-folder-next-message-number-dop (folder)
+  (let ((number-list (sort (elmo-folder-list-messages folder nil 'in-msgdb) '>))
+       (spool-folder (elmo-dop-spool-folder folder))
+       spool-length
+       max-num)
+    (setq spool-length (or (if (elmo-folder-exists-p spool-folder)
+                              (car (elmo-folder-status spool-folder)))
+                          0))
+    (setq max-num (or (car number-list) 0))
+    (+ max-num spool-length)))
+
 ;;; Delayed operation (executed at online status).
 (defun elmo-folder-append-buffer-dop-delayed (folder flag number set-number)
   (let ((spool-folder (elmo-dop-spool-folder folder))
@@ -332,17 +343,19 @@ FOLDER is the folder structure."
       t)))
 
 (defun elmo-folder-delete-messages-dop-delayed (folder number-alist)
-  (elmo-folder-delete-messages
-   folder
-   ;; messages are deleted only if message-id is not changed.
-   (mapcar 'car
-          (elmo-delete-if
-           (lambda (pair)
-             (not (string=
-                   (cdr pair)
-                   (elmo-message-fetch-field folder (car pair)
-                                             'message-id))))
-           number-alist))))
+  (ignore-errors
+    (elmo-folder-delete-messages
+     folder
+     ;; messages are deleted only if message-id is not changed.
+     (mapcar 'car
+            (elmo-delete-if
+             (lambda (pair)
+               (not (string=
+                     (cdr pair)
+                     (elmo-message-fetch-field folder (car pair)
+                                               'message-id))))
+             number-alist)))
+    t)) ; Always success (If failure, just remain)
 
 (defun elmo-folder-create-dop-delayed (folder)
   (unless (elmo-folder-exists-p folder)
index 88144ee..f2dda4b 100644 (file)
@@ -2596,6 +2596,28 @@ If optional argument REMOVE is non-nil, remove FLAG."
            (string= (elmo-net-folder-user-internal (, folder1))
                     (elmo-net-folder-user-internal (, folder2)))))))
 
+(luna-define-method elmo-folder-next-message-number-plugged
+  ((folder elmo-imap4-folder))
+  (let ((session (elmo-imap4-get-session folder))
+       messages new unread response killed uidnext)
+    (with-current-buffer (elmo-network-session-buffer session)
+      (setq elmo-imap4-status-callback nil)
+      (setq elmo-imap4-status-callback-data nil))
+    (if elmo-imap4-use-select-to-update-status
+       (elmo-imap4-session-select-mailbox
+        session
+        (elmo-imap4-folder-mailbox-internal folder)))
+    (setq response
+         (elmo-imap4-send-command-wait session
+                                       (list
+                                        "status "
+                                        (elmo-imap4-mailbox
+                                         (elmo-imap4-folder-mailbox-internal
+                                          folder))
+                                        " (uidnext)"))
+         response (elmo-imap4-response-value response 'status))
+    (elmo-imap4-response-value response 'uidnext)))
+
 (luna-define-method elmo-folder-append-messages :around
   ((folder elmo-imap4-folder) src-folder numbers &optional same-number)
   (if (and (eq (elmo-folder-type-internal src-folder) 'imap4)
index 9322ca5..3dd3594 100644 (file)
   (let ((numbers (mapcar
                  'car
                  (elmo-map-folder-location-alist-internal folder))))
-    (setq numbers (elmo-living-messages numbers (elmo-folder-killed-list-internal folder)))
+    (setq numbers (elmo-living-messages
+                  numbers
+                  (elmo-folder-killed-list-internal folder)))
     (prog1
        (cons (elmo-max-of-list numbers)
              (length numbers))
 (luna-define-method elmo-folder-close-internal ((folder elmo-map-folder))
   (elmo-map-folder-set-location-alist-internal folder nil)
   (elmo-map-folder-set-location-hash-internal folder nil))
-  
+
 (luna-define-method elmo-folder-check ((folder elmo-map-folder))
   (elmo-map-folder-update-locations
    folder
    (elmo-map-folder-list-message-locations folder)))
 
+(luna-define-method elmo-folder-next-message-number ((folder elmo-map-folder))
+  (1+ (elmo-map-folder-number-max-internal folder)))
+
 (luna-define-method elmo-folder-clear :around ((folder elmo-map-folder)
                                               &optional keep-killed)
   (unless keep-killed
            (concat "#" (int-to-string number))
            (elmo-map-folder-location-hash-internal
             folder))
-          (elmo-map-folder-location-alist-internal folder))))
+          (elmo-map-folder-location-alist-internal folder)))
+    (elmo-clear-hash-val (concat "#" (int-to-string number))
+                        (elmo-map-folder-location-hash-internal
+                         folder)))
   t) ; success
 
 (require 'product)
index 9ec6022..a479597 100644 (file)
@@ -362,6 +362,17 @@ Returned value is searched from `elmo-network-stream-type-alist'."
       (elmo-folder-status-dop folder)
     (error "Unplugged")))
 
+(luna-define-method elmo-folder-next-message-number ((folder elmo-net-folder))
+  (if (elmo-folder-plugged-p folder)
+      (elmo-folder-send folder 'elmo-folder-next-message-number-plugged)
+    (elmo-folder-send folder 'elmo-folder-next-message-number-unplugged)))
+
+(luna-define-method elmo-folder-next-message-number-unplugged
+  ((folder elmo-net-folder))
+  (if elmo-enable-disconnected-operation
+      (elmo-folder-next-message-number-dop folder)
+    (error "Unplugged")))
+
 (luna-define-method elmo-folder-list-messages-internal
   ((folder elmo-net-folder) &optional nohide)
   (elmo-net-folder-list-messages-internal folder nohide))
index 53499cc..5d60256 100644 (file)
@@ -380,6 +380,10 @@ If IS-LOCAL is non-nil, only the local flag is updated.")
 FOLDER is the ELMO folder structure.
 If IS-LOCAL is non-nil, only the local flag is updated.")
 
+(luna-define-generic elmo-folder-next-message-number (folder)
+  "The next message number that will be assigned to a new message.
+FOLDER is the ELMO folder structure.")
+
 (luna-define-generic elmo-folder-append-buffer (folder &optional flag
                                                       number)
   "Append current buffer as a new message.
@@ -955,6 +959,10 @@ Return a cons cell of (NUMBER-CROSSPOSTS . NEW-FLAG-ALIST).")
 (luna-define-method elmo-folder-contains-type ((folder elmo-folder) type)
   (eq (elmo-folder-type-internal folder) type))
 
+(luna-define-method elmo-folder-next-message-number ((folder elmo-folder))
+  (+ 1 (elmo-max-of-list (or (elmo-folder-list-messages folder)
+                            '(0)))))
+
 (luna-define-method elmo-folder-append-messages ((folder elmo-folder)
                                                 src-folder
                                                 numbers
@@ -1195,8 +1203,6 @@ NUMBER is a number of the message.
 FIELD is a symbol of the field.")
 
 (luna-define-method elmo-message-field ((folder elmo-folder) number field)
-  (when (zerop (elmo-folder-length folder))
-    (error "Cannot treat this folder correctly."))
   (elmo-message-entity-field (elmo-message-entity folder number) field))
 
 (luna-define-method elmo-message-use-cache-p ((folder elmo-folder) number)
index dda4a93..fc692f4 100644 (file)
@@ -1,3 +1,8 @@
+2003-10-15  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * im-wl.el (wl-draft-send-with-imput-async): Follow the changes
+       in draft (Not tested).
+
 2003-09-23  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * wl-addrbook.el (wl-summary-addrbook-from): Use
index 92a8f57..5f9e954 100644 (file)
@@ -75,12 +75,20 @@ This is most commonly `imput(impost)' or `inews-nifty4u'.")
   (let (buffer-process process-connection-type watch-buffer
        (sending-buffer (current-buffer))
        (error-msg-regexp im-wl-dispatcher-error-msg)
-       (msg (save-excursion
-              (set-buffer editing-buffer)
-              (or wl-draft-buffer-file-name
-                  (setq wl-draft-buffer-file-name
-                        (expand-file-name
-                         im-wl-default-temp-file-name))))))
+       (number wl-draft-buffer-message-number)
+       msg)
+    (with-current-buffer editing-buffer
+      (if (elmo-message-file-p
+          (wl-folder-get-elmo-folder wl-draft-folder)
+          number)
+         (setq msg
+               (elmo-message-file-name
+                (wl-folder-get-elmo-folder wl-draft-folder)
+                number))
+       (with-temp-file (setq msg (make-temp-file "im-wl"))
+         (elmo-message-fetch (wl-folder-get-elmo-folder wl-draft-folder)
+                             number (elmo-make-fetch-strategy 'entire)
+                             nil (current-buffer)))))
     ;; current buffer is raw buffer.
     (save-excursion
       (goto-char (point-max))
index 3854c1f..85e0d4c 100644 (file)
@@ -1,5 +1,35 @@
 2003-10-15  Yuuichi Teranishi  <teranisi@gohome.org>
 
+       * wl.el (wl-check-environment): Don't check wl-draft-folder is file.
+
+       * wl-vars.el (wl-folder-sync-range-alist): Changed default value.
+
+       * wl-util.el (wl-require-update-all-folder-p): New function.
+       (wl-get-assoc-list-value): Added `function' to match directive.
+       (wl-collect-draft): Rewrite.
+
+       * wl-summary.el (wl-summary-sync-update): Clear faces
+       when both wl-summary-lazy-highlight and wl-summary-lazy-update-mark
+       are non-nil.
+       (wl-summary-get-sync-range): Call wl-get-assoc-list-value with match
+       argument as function.
+       (wl-summary-input-range): Ditto.
+
+       * wl-folder.el (wl-draft-get-folder): New function.
+       (wl-folder-get-elmo-folder): Consider draft folder.
+
+       * wl-draft.el (wl-draft-buf-name, wl-draft-buffer-file-name): Abolish.
+       (wl-draft-buffer-message-number): New buffer local variable.
+       (wl-draft-folder-internal): New internal variable.
+       (wl-draft-delete): Rewrite.
+       (wl-draft-save): Ditto.
+       (wl-draft-create-buffer): Use wl-draft-get-folder instead of
+       wl-folder-get-elmo-folder.
+       (wl-draft-config-info-operation): Ditto.
+       (wl-jump-to-draft-folder): Ditto.
+       (wl-draft-prepare-edit): Set up auto-save-file-name-transforms.
+       (wl-draft-reedit): Rewrite.
+
        * Version number is increased to 2.11.19.
        
 2003-10-09  Tetsurou Okazaki  <okazaki@be.to>
index ed70eb4..85fcdf9 100644 (file)
@@ -43,6 +43,7 @@
 (defvar mail-from-style)
 
 (eval-when-compile
+  (require 'static)
   (require 'elmo-pop3)
   (defalias-maybe 'x-face-insert 'ignore)
   (defalias-maybe 'x-face-insert-version-header 'ignore)
@@ -52,8 +53,7 @@
 (eval-and-compile
   (autoload 'wl-addrmgr "wl-addrmgr"))
 
-(defvar wl-draft-buf-name "Draft")
-(defvar wl-draft-buffer-file-name nil)
+(defvar wl-draft-buffer-message-number nil)
 (defvar wl-draft-field-completion-list nil)
 (defvar wl-draft-verbose-send t)
 (defvar wl-draft-verbose-msg nil)
@@ -109,7 +109,7 @@ e.g.
     (template          . wl-draft-config-sub-template)
     (x-face            . wl-draft-config-sub-x-face)))
 
-(make-variable-buffer-local 'wl-draft-buffer-file-name)
+(make-variable-buffer-local 'wl-draft-buffer-message-number)
 (make-variable-buffer-local 'wl-draft-buffer-cur-summary-buffer)
 (make-variable-buffer-local 'wl-draft-config-variables)
 (make-variable-buffer-local 'wl-draft-config-exec-flag)
@@ -120,6 +120,9 @@ e.g.
 (make-variable-buffer-local 'wl-draft-parent-folder)
 (make-variable-buffer-local 'wl-draft-parent-number)
 
+(defvar wl-draft-folder-internal nil
+  "Internal variable for caching `opened' draft folder.")
+
 (defsubst wl-smtp-password-key (user mechanism server)
   (format "SMTP:%s/%s@%s"
          user mechanism server))
@@ -740,15 +743,12 @@ Reply to author if WITH-ARG is non-nil."
   (save-excursion
     (when editing-buffer
       (set-buffer editing-buffer)
-      (if wl-draft-buffer-file-name
-         (progn
-           (if (file-exists-p wl-draft-buffer-file-name)
-               (delete-file wl-draft-buffer-file-name))
-           (let ((msg (and wl-draft-buffer-file-name
-                           (string-match "[0-9]+$" wl-draft-buffer-file-name)
-                           (string-to-int
-                            (match-string 0 wl-draft-buffer-file-name)))))
-             (wl-draft-config-info-operation msg 'delete))))
+      (when wl-draft-buffer-message-number
+       (elmo-folder-delete-messages (wl-draft-get-folder)
+                                    (list
+                                     wl-draft-buffer-message-number))
+       (wl-draft-config-info-operation wl-draft-buffer-message-number
+                                       'delete))
       (set-buffer-modified-p nil)              ; force kill
       (kill-buffer editing-buffer))))
 
@@ -1404,39 +1404,48 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
            (let (wl-interactive-send)
              (wl-draft-send 'kill-when-done))))))))
 
-;; Derived from `message-save-drafts' in T-gnus.
 (defun wl-draft-save ()
   "Save current draft."
   (interactive)
   (if (buffer-modified-p)
       (progn
-       (message "Saving %s..." wl-draft-buffer-file-name)
-       (let ((msg (buffer-substring-no-properties (point-min) (point-max))))
-         (with-temp-file wl-draft-buffer-file-name
+       (message "Saving...")
+       (let ((msg (buffer-substring-no-properties (point-min) (point-max)))
+             next-number)
+         (when wl-draft-buffer-message-number
+           (elmo-folder-delete-messages (wl-draft-get-folder)
+                                        (list wl-draft-buffer-message-number))
+           (wl-draft-config-info-operation wl-draft-buffer-message-number
+                                           'delete))
+         (elmo-folder-check (wl-draft-get-folder))
+         ;; If no header separator, insert it.
+         (with-temp-buffer
            (insert msg)
-           ;; If no header separator, insert it.
-           (save-excursion
+           (goto-char (point-min))
+           (unless (re-search-forward
+                    (concat "^" (regexp-quote mail-header-separator) "$")
+                    nil t)
              (goto-char (point-min))
-             (unless (re-search-forward
-                      (concat "^" (regexp-quote mail-header-separator) "$")
-                      nil t)
-               (goto-char (point-min))
-               (if (re-search-forward "\n\n" nil t)
-                   (replace-match (concat "\n" mail-header-separator "\n"))
-                 (goto-char (point-max))
-                 (insert (if (eq (char-before) ?\n) "" "\n")
-                         mail-header-separator "\n"))))
+             (if (re-search-forward "\n\n" nil t)
+                 (replace-match (concat "\n" mail-header-separator "\n"))
+               (goto-char (point-max))
+               (insert (if (eq (char-before) ?\n) "" "\n")
+                       mail-header-separator "\n")))
            (let ((mime-header-encode-method-alist
                   '((eword-encode-unstructured-field-body))))
              (mime-edit-translate-buffer))
-           (wl-draft-get-header-delimiter t)))
-       (set-buffer-modified-p nil)
-       (wl-draft-config-info-operation
-        (and (string-match "[0-9]+$" wl-draft-buffer-file-name)
-             (string-to-int
-              (match-string 0 wl-draft-buffer-file-name)))
-        'save)
-       (message "Saving %s...done" wl-draft-buffer-file-name))
+           (wl-draft-get-header-delimiter t)
+           (setq next-number
+                 (elmo-folder-next-message-number (wl-draft-get-folder)))
+           (elmo-folder-append-buffer (wl-draft-get-folder)))
+         (elmo-folder-check (wl-draft-get-folder))
+         (elmo-folder-commit (wl-draft-get-folder))
+         (setq wl-draft-buffer-message-number next-number)
+         (rename-buffer (format "%s/%d" wl-draft-folder next-number))
+         (setq buffer-file-name (buffer-name))
+         (set-buffer-modified-p nil)
+         (wl-draft-config-info-operation wl-draft-buffer-message-number 'save)
+         (message "Saving...done")))
     (message "(No changes need to be saved)")))
 
 (defun wl-draft-mimic-kill-buffer ()
@@ -1620,10 +1629,8 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
     (wl-init)) ; returns immediately if already initialized.
 
 
-  (let (buf-name header-alist-internal)
-    (setq buf-name
-         (wl-draft-create-buffer parent-folder))
-
+  (let (buffer header-alist-internal)
+    (setq buffer (wl-draft-create-buffer parent-folder))
     (unless (cdr (assq 'From header-alist))
       (setq header-alist
            (append (list (cons 'From wl-from)) header-alist)))
@@ -1663,10 +1670,10 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
           (mail-position-on-field "To"))
          (t
           (goto-char (point-max))))
-    buf-name))
+    buffer))
 
 (defun wl-draft-create-buffer (&optional parent-folder)
-  (let* ((draft-folder (wl-folder-get-elmo-folder wl-draft-folder))
+  (let* ((draft-folder (wl-draft-get-folder))
         (parent-folder (or parent-folder (wl-summary-buffer-folder-name)))
         (summary-buf (wl-summary-get-buffer parent-folder))
         (reply-or-forward
@@ -1675,37 +1682,26 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
              (eq this-command 'wl-summary-forward)
              (eq this-command 'wl-summary-target-mark-forward)
              (eq this-command 'wl-summary-target-mark-reply-with-citation)))
-        buf-name file-name num change-major-mode-hook)
-    (if (not (elmo-folder-message-file-p draft-folder))
-       (error "%s folder cannot be used for draft folder" wl-draft-folder))
-    (setq num (elmo-max-of-list
-              (or (elmo-folder-list-messages draft-folder) '(0))))
-    (setq num (+ 1 num))
-    ;; To get unused buffer name.
-    (while (get-buffer (concat wl-draft-folder "/" (int-to-string num)))
-      (setq num (+ 1 num)))
-    (setq buf-name (find-file-noselect
-                   (setq file-name
-                         (elmo-message-file-name
-                          (wl-folder-get-elmo-folder wl-draft-folder)
-                          num))))
+        (buffer (generate-new-buffer "*draft*")) ; Just for initial name.
+        change-major-mode-hook)
+    (set-buffer buffer)
     ;; switch-buffer according to draft buffer style.
     (if wl-draft-use-frame
-       (switch-to-buffer-other-frame buf-name)
+       (switch-to-buffer-other-frame buffer)
       (if reply-or-forward
          (case wl-draft-reply-buffer-style
            (split
             (split-window-vertically)
             (other-window 1)
-            (switch-to-buffer buf-name))
+            (switch-to-buffer buffer))
            (keep
-            (switch-to-buffer buf-name))
+            (switch-to-buffer buffer))
            (full
             (delete-other-windows)
-            (switch-to-buffer buf-name))
+            (switch-to-buffer buffer))
            (t
             (if (functionp wl-draft-reply-buffer-style)
-                (funcall wl-draft-reply-buffer-style buf-name)
+                (funcall wl-draft-reply-buffer-style buffer)
               (error "Invalid value for wl-draft-reply-buffer-style"))))
        (case wl-draft-buffer-style
          (split
@@ -1713,19 +1709,15 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
             (wl-summary-toggle-disp-msg 'off))
           (split-window-vertically)
           (other-window 1)
-          (switch-to-buffer buf-name))
+          (switch-to-buffer buffer))
          (keep
-          (switch-to-buffer buf-name))
+          (switch-to-buffer buffer))
          (full
           (delete-other-windows)
-          (switch-to-buffer buf-name))
+          (switch-to-buffer buffer))
          (t (if (functionp wl-draft-buffer-style)
-                (funcall wl-draft-buffer-style buf-name)
+                (funcall wl-draft-buffer-style buffer)
               (error "Invalid value for wl-draft-buffer-style"))))))
-    (set-buffer buf-name)
-    (if (not (string-match (regexp-quote wl-draft-folder)
-                          (buffer-name)))
-       (rename-buffer (concat wl-draft-folder "/" (int-to-string num))))
     (auto-save-mode -1)
     (wl-draft-mode)
     (make-local-variable 'truncate-partial-width-windows)
@@ -1733,12 +1725,11 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
     (setq truncate-lines wl-draft-truncate-lines)
     (setq wl-sent-message-via nil)
     (setq wl-sent-message-queued nil)
-    (setq wl-draft-buffer-file-name file-name)
     (setq wl-draft-config-exec-flag t)
     (setq wl-draft-parent-folder (or parent-folder ""))
     (or (eq this-command 'wl-folder-write-current-folder)
        (setq wl-draft-buffer-cur-summary-buffer summary-buf))
-    buf-name))
+    buffer))
 
 (defun wl-draft-create-contents (header-alist)
   "header-alist' sample
@@ -1789,6 +1780,17 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
     (error "`wl-draft-create-header' must be use in wl-draft-mode"))
   (let (change-major-mode-hook)
     (wl-draft-editor-mode)
+    (static-when (boundp 'auto-save-file-name-transforms)
+      (make-local-variable 'auto-save-file-name-transforms)
+      (setq auto-save-file-name-transforms
+           (cons (list (concat (regexp-quote wl-draft-folder)
+                               "/\\([0-9]+\\)")
+                       (concat (expand-file-name
+                                "auto-save-"
+                                (elmo-folder-msgdb-path
+                                 (wl-draft-get-folder)))
+                               "\\1"))
+                 auto-save-file-name-transforms)))
     (when wl-draft-write-file-function
       (add-hook 'local-write-file-hooks wl-draft-write-file-function))
     (wl-draft-overload-functions)
@@ -1954,68 +1956,55 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
     (delete-region (point-at-bol)(1+ (point-at-eol)))))
 
 (defun wl-draft-reedit (number)
-  (let ((draft-folder (wl-folder-get-elmo-folder wl-draft-folder))
+  (let ((draft-folder (wl-draft-get-folder))
        (wl-draft-reedit t)
-       buffer file-name change-major-mode-hook body-top)
-    (setq file-name (elmo-message-file-name draft-folder number))
-    (unless (file-exists-p file-name)
-      (error "File %s does not exist" file-name))
-    (if (setq buffer (get-buffer
-                     (concat wl-draft-folder "/"
-                             (number-to-string number))))
-       (progn
-         (if wl-draft-use-frame
-             (switch-to-buffer-other-frame buffer)
-           (switch-to-buffer buffer))
-         (set-buffer buffer))
-      (setq buffer (get-buffer-create (number-to-string number)))
-      ;; switch-buffer according to draft buffer style.
-      (if wl-draft-use-frame
-         (switch-to-buffer-other-frame buffer)
-       (case wl-draft-buffer-style
-         (split
-          (split-window-vertically)
-          (other-window 1)
-          (switch-to-buffer buffer))
-         (keep
-          (switch-to-buffer buffer))
-         (full
-          (delete-other-windows)
-          (switch-to-buffer buffer))
-         (t (if (functionp wl-draft-buffer-style)
-                (funcall wl-draft-buffer-style buffer)
-              (error "Invalid value for wl-draft-buffer-style")))))
-      (set-buffer buffer)
-      (setq wl-draft-parent-folder "")
-      (insert-file-contents-as-binary file-name)
-      (elmo-delete-cr-buffer)
-      (let((mime-edit-again-ignored-field-regexp
-           "^\\(Content-.*\\|Mime-Version\\):"))
-       (wl-draft-decode-message-in-buffer))
-      (setq body-top (wl-draft-insert-mail-header-separator))
-      (if (not (string-match (regexp-quote wl-draft-folder)
-                            (buffer-name)))
-         (rename-buffer (concat wl-draft-folder "/" (buffer-name))))
-      (auto-save-mode -1)
-      (wl-draft-mode)
-      (setq buffer-file-name file-name)
-      (make-local-variable 'truncate-partial-width-windows)
-      (setq truncate-partial-width-windows nil)
-      (setq truncate-lines wl-draft-truncate-lines)
-      (setq wl-sent-message-via nil)
-      (setq wl-sent-message-queued nil)
-      (setq wl-draft-buffer-file-name file-name)
-      (wl-draft-config-info-operation number 'load)
-      (goto-char (point-min))
-      (wl-draft-overload-functions)
-      (wl-draft-editor-mode)
-      (when wl-draft-write-file-function
-       (add-hook 'local-write-file-hooks wl-draft-write-file-function))
-      (wl-highlight-headers 'for-draft)
-      (goto-char body-top)
-      (run-hooks 'wl-draft-reedit-hook)
-      (goto-char (point-max))
-      buffer)))
+       (num 0)
+       buffer change-major-mode-hook body-top)
+    (setq buffer (get-buffer-create (format "%s/%d" wl-draft-folder
+                                           number)))
+    (if wl-draft-use-frame
+       (switch-to-buffer-other-frame buffer)
+      (switch-to-buffer buffer))
+    (set-buffer buffer)
+    (elmo-message-fetch draft-folder number (elmo-make-fetch-strategy 'entire)
+                       nil (current-buffer))
+    (elmo-delete-cr-buffer)
+    (let ((mime-edit-again-ignored-field-regexp
+          "^\\(Content-.*\\|Mime-Version\\):"))
+      (wl-draft-decode-message-in-buffer))
+    (setq body-top (wl-draft-insert-mail-header-separator))
+    (auto-save-mode -1)
+    (wl-draft-mode)
+    (make-local-variable 'truncate-partial-width-windows)
+    (setq truncate-partial-width-windows nil)
+    (setq truncate-lines wl-draft-truncate-lines)
+    (setq wl-sent-message-via nil)
+    (setq wl-sent-message-queued nil)
+    (wl-draft-config-info-operation number 'load)
+    (goto-char (point-min))
+    (wl-draft-overload-functions)
+    (wl-draft-editor-mode)
+    (static-when (boundp 'auto-save-file-name-transforms)
+      (make-local-variable 'auto-save-file-name-transforms)
+      (setq auto-save-file-name-transforms
+           (cons (list (concat (regexp-quote wl-draft-folder)
+                               "/\\([0-9]+\\)")
+                       (concat (expand-file-name
+                                "auto-save-"
+                                (elmo-folder-msgdb-path
+                                 (wl-draft-get-folder)))
+                               "\\1"))
+                 auto-save-file-name-transforms)))
+    (setq buffer-file-name (buffer-name)
+         wl-draft-parent-folder ""
+         wl-draft-buffer-message-number number)
+    (when wl-draft-write-file-function
+      (add-hook 'local-write-file-hooks wl-draft-write-file-function))
+    (wl-highlight-headers 'for-draft)
+    (goto-char body-top)
+    (run-hooks 'wl-draft-reedit-hook)
+    (goto-char (point-max))
+    buffer))
 
 (defmacro wl-draft-body-goto-top ()
   (` (progn
@@ -2236,8 +2225,7 @@ Automatically applied in draft sending time."
            (insert (concat field ": " content "\n"))))))))
 
 (defun wl-draft-config-info-operation (msg operation)
-  (let* ((msgdb-dir (elmo-folder-msgdb-path (wl-folder-get-elmo-folder
-                                            wl-draft-folder)))
+  (let* ((msgdb-dir (elmo-folder-msgdb-path (wl-draft-get-folder)))
         (filename
          (expand-file-name
           (format "%s-%d" wl-draft-config-save-filename msg)
@@ -2409,8 +2397,7 @@ Automatically applied in draft sending time."
        (switch-to-buffer buf))))))
 
 (defun wl-jump-to-draft-folder ()
-  (let ((msgs (reverse (elmo-folder-list-messages (wl-folder-get-elmo-folder
-                                                  wl-draft-folder))))
+  (let ((msgs (reverse (elmo-folder-list-messages (wl-draft-get-folder))))
        (mybuf (buffer-name))
        msg buf)
     (if (not msgs)
index 565c48c..fd45c0a 100644 (file)
@@ -323,12 +323,25 @@ Default HASHTB is `wl-folder-elmo-folder-hashtb'."
   (` (elmo-set-hash-val (, name) (, folder)
                        (or (, hashtb) wl-folder-elmo-folder-hashtb))))
 
+(defun wl-draft-get-folder ()
+  "A function to obtain `opened' draft elmo folder structure."
+  (if (and wl-draft-folder-internal
+          (string= (elmo-folder-name-internal wl-draft-folder-internal)
+                   wl-draft-folder))
+      wl-draft-folder-internal
+    (setq wl-draft-folder-internal (elmo-make-folder wl-draft-folder))
+    (wl-folder-confirm-existence wl-draft-folder-internal)
+    (elmo-folder-open wl-draft-folder-internal 'load-msgdb)
+    wl-draft-folder-internal))
+
 (defmacro wl-folder-get-elmo-folder (entity &optional no-cache)
   "Get elmo folder structure from ENTITY."
-  (` (if (, no-cache)
-        (elmo-make-folder (elmo-string (, entity)))
-       (or (wl-folder-elmo-folder-cache-get (, entity))
-          (let* ((name (elmo-string (, entity)))
+  `(if ,no-cache
+       (elmo-make-folder (elmo-string ,entity))
+     (if (string= (elmo-string ,entity) wl-draft-folder)
+        (wl-draft-get-folder)
+       (or (wl-folder-elmo-folder-cache-get ,entity)
+          (let* ((name (elmo-string ,entity))
                  (folder (elmo-make-folder name)))
             (wl-folder-elmo-folder-cache-put name folder)
             folder)))))
index 0695500..a11a2da 100644 (file)
@@ -1821,6 +1821,11 @@ This function is defined for `window-scroll-functions'"
                  (wl-summary-delete-messages-on-buffer delete-list))
                (unless wl-summary-lazy-update-mark
                  (wl-summary-update-status-marks (point-min) (point-max)))
+               (when (and wl-summary-lazy-highlight
+                          wl-summary-lazy-update-mark)
+                 (let (buffer-read-only)
+                   (put-text-property (point-min) (point-max) 'face nil))
+                 (run-hooks 'wl-summary-buffer-window-scroll-functions))
                (setq num (length append-list))
                (setq i 0)
                (setq wl-summary-delayed-update nil)
@@ -3356,7 +3361,8 @@ Return non-nil if the mark is updated"
               (elmo-folder-plugged-p folder)
               (wl-get-assoc-list-value
                wl-folder-sync-range-alist
-               (elmo-folder-name-internal folder)))
+               (elmo-folder-name-internal folder)
+               'function))
              wl-default-sync-range)))
 
 ;; redefined for wl-summary-sync-update
@@ -3376,7 +3382,8 @@ Return non-nil if the mark is updated"
                            "all-entirely"))
        (default (or (wl-get-assoc-list-value
                      wl-folder-sync-range-alist
-                     folder)
+                     folder
+                     'function)
                     wl-default-sync-range))
        range)
     (setq range
index 079ea48..19885ae 100644 (file)
@@ -164,6 +164,11 @@ If HACK-ADDRESSES is t, then the strings are considered to be mail addresses,
          (funcall func))
       (wl-push (cdr keve) unread-command-events))))
 
+(defun wl-require-update-all-folder-p (name)
+  "Return non-nil if NAME is draft or queue folder."
+  (or (string= name wl-draft-folder)
+      (string= name wl-queue-folder)))
+
 ;(defalias 'wl-make-hash 'elmo-make-hash)
 ;;(make-obsolete 'wl-make-hash 'elmo-make-hash)
 
@@ -260,13 +265,17 @@ even when invalid character is contained."
          value pair)
       (while alist
        (setq pair (car alist))
-       (if (string-match (car pair) folder)
-           (cond ((eq match 'all)
-                  (setq value (append value (list (cdr pair)))))
-                 ((eq match 'all-list)
-                  (setq value (append value (cdr pair))))
-                 ((not match)
-                  (throw 'found (cdr pair)))))
+       (if (and (eq match 'function)
+                (functionp (car pair)))
+           (when (funcall (car pair) folder)
+             (throw 'found (cdr pair)))
+         (if (string-match (car pair) folder)
+             (cond ((eq match 'all)
+                    (setq value (append value (list (cdr pair)))))
+                   ((eq match 'all-list)
+                    (setq value (append value (cdr pair))))
+                   ((not match)
+                    (throw 'found (cdr pair))))))
        (setq alist (cdr alist)))
       value)))
 
@@ -570,16 +579,14 @@ that `read' can handle, whenever this is possible."
 
 (defun wl-collect-draft ()
   (let ((draft-regexp (concat
-                      "^" (regexp-quote
-                           (elmo-localdir-folder-directory-internal
-                            (wl-folder-get-elmo-folder wl-draft-folder)))))
+                      "^" (regexp-quote wl-draft-folder)))
        result buf)
     (mapcar
      (function (lambda (x)
-                (if (and
-                     (setq buf (with-current-buffer x
-                                 wl-draft-buffer-file-name))
-                     (string-match draft-regexp buf))
+                (if (with-current-buffer x
+                      (and (eq major-mode 'wl-draft-mode)
+                           (buffer-name)
+                           (string-match draft-regexp (buffer-name))))
                     (setq result (nconc result (list x))))))
      (buffer-list))
     result))
index 6f291e0..c9d3242 100644 (file)
@@ -2204,12 +2204,11 @@ e.x.
   :group 'wl-pref)
 
 (defcustom wl-folder-sync-range-alist
-  (list (cons (concat "^" (regexp-quote wl-draft-folder) "$\\|^"
-                     (regexp-quote wl-queue-folder) "$")
-             "all")
+  (list (cons 'wl-require-update-all-folder-p "all")
        (cons "^'flag" "all"))
   "*Default sync range alist.  If no matches, `wl-default-sync-range' is used."
-  :type '(repeat (cons (regexp :tag "Folder Regexp")
+  :type '(repeat (cons (choice (regexp :tag "Folder Regexp")
+                              (symbol :tag "A function"))
                       (choice (const "update")
                               (const "all")
                               (const "rescan")
index 1aea805..26d3f7d 100644 (file)
--- a/wl/wl.el
+++ b/wl/wl.el
@@ -730,8 +730,6 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
          (queue-folder (wl-folder-get-elmo-folder wl-queue-folder))
          (lost+found-folder (wl-folder-get-elmo-folder
                              elmo-lost+found-folder)))
-      (if (not (elmo-folder-message-file-p draft-folder))
-         (error "%s is not allowed for draft folder" wl-draft-folder))
       (unless (elmo-folder-exists-p draft-folder)
        (if (y-or-n-p
             (format "Draft Folder %s does not exist, create it? "