* elmo.el (message-number-changed): Define new signal.
authoryoichi <yoichi>
Mon, 7 Mar 2005 12:04:36 +0000 (12:04 +0000)
committeryoichi <yoichi>
Mon, 7 Mar 2005 12:04:36 +0000 (12:04 +0000)
* elmo-dop.el (elmo-folder-append-buffer-dop-delayed): Emit
message-number-changed signal.
* elmo-localdir.el (elmo-folder-pack-numbers): Ditto.
* elmo-map.el (elmo-folder-pack-numbers): Ditto.
Respect `elmo-pack-number-check-strict'.

* wl-draft.el (wl-draft-config-info-filename): Extracted from
`wl-draft-config-info-operation'.
(wl-draft-buffer-change-number): New function.
(wl-draft-rename-saved-config): Ditto.
* wl.el (wl-init): Connect slot for message-number-changed.
(toplevel): Add autoload for wl-draft-rename-saved-config.

elmo/ChangeLog
elmo/elmo-dop.el
elmo/elmo-localdir.el
elmo/elmo-map.el
elmo/elmo.el
wl/ChangeLog
wl/wl-draft.el
wl/wl.el

index ba7bcc8..6bd339a 100644 (file)
@@ -1,3 +1,12 @@
+2005-03-07  Yoichi NAKAYAMA  <yoichi@geiin.org>
+
+       * elmo.el (message-number-changed): Define new signal.
+       * elmo-dop.el (elmo-folder-append-buffer-dop-delayed): Emit
+       message-number-changed signal.
+       * elmo-localdir.el (elmo-folder-pack-numbers): Ditto.
+       * elmo-map.el (elmo-folder-pack-numbers): Ditto.
+       Respect `elmo-pack-number-check-strict'.
+
 2005-03-06  Yoichi NAKAYAMA  <yoichi@geiin.org>
 
        * elmo-signal.el (elmo-connect-signal): Document.
index 73d7fc6..33de027 100644 (file)
@@ -349,7 +349,11 @@ FOLDER is the folder structure."
                              (t
                               (list flag)))))
        (when (or (condition-case nil
-                     (elmo-folder-append-buffer folder flags set-number)
+                     (let ((new-num (elmo-folder-next-message-number folder)))
+                       (prog1
+                           (elmo-folder-append-buffer folder flags set-number)
+                         (elmo-emit-signal 'message-number-changed
+                                           folder (- number) new-num)))
                    (error))
                  ;; Append failed...
                  (elmo-folder-append-buffer
index 82eeb4d..5a2ea59 100644 (file)
          (elmo-message-entity-set-number entity new-number))
        (elmo-msgdb-append-entity new-msgdb entity
                                  (elmo-msgdb-flags msgdb old-number))
+       (elmo-emit-signal 'message-number-changed folder old-number new-number)
        (setq new-number (1+ new-number))))
     (message "Packing...done")
     (elmo-folder-set-msgdb-internal folder new-msgdb)))
index 08f23df..adac358 100644 (file)
 
 (luna-define-method elmo-folder-pack-numbers ((folder elmo-map-folder))
   (let* ((msgdb (elmo-folder-msgdb folder))
-        (numbers (sort (elmo-folder-list-messages folder nil 'in-msgdb) '<))
+        (numbers
+         (sort (elmo-folder-list-messages folder nil
+                                          (not elmo-pack-number-check-strict))
+               '<))
         (new-msgdb (elmo-make-msgdb (elmo-folder-msgdb-path folder)))
         (number 1)
         total location entity)
              (cons (cons number
                          (elmo-map-message-location folder old-number))
                    location))
+       (elmo-emit-signal 'message-number-changed folder old-number number)
        (setq number (1+ number))))
     (message "Packing...done")
     (elmo-map-folder-location-setup folder (nreverse location))
index bc273b7..cd583f7 100644 (file)
@@ -101,6 +101,9 @@ Otherwise, entire fetching of the message is aborted without confirmation."
 (elmo-define-signal update-overview (number)
   "Notify update overview of the message with NUMBER.")
 
+(elmo-define-signal message-number-changed (old-number new-number)
+  "Notify change of message number within the folder.")
+
 ;; autoloads
 (eval-and-compile
   (autoload 'md5 "md5")
index c00cc2a..39eb120 100644 (file)
@@ -1,3 +1,12 @@
+2005-03-07  Yoichi NAKAYAMA  <yoichi@geiin.org>
+
+       * wl-draft.el (wl-draft-config-info-filename): Extracted from
+       `wl-draft-config-info-operation'.
+       (wl-draft-buffer-change-number): New function.
+       (wl-draft-rename-saved-config): Ditto.
+       * wl.el (wl-init): Connect slot for message-number-changed.
+       (toplevel): Add autoload for wl-draft-rename-saved-config.
+
 2005-03-05  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * wl-summary.el (wl-summary-buffer-attach): Connect to signal
index d5e6d9d..13ba443 100644 (file)
@@ -2242,12 +2242,14 @@ Automatically applied in draft sending time."
            (goto-char (point-max))
            (insert (concat field ": " content "\n"))))))))
 
+(defsubst wl-draft-config-info-filename (number msgdb-dir)
+  (expand-file-name
+   (format "%s-%d" wl-draft-config-save-filename number)
+   msgdb-dir))
+
 (defun wl-draft-config-info-operation (msg operation)
   (let* ((msgdb-dir (elmo-folder-msgdb-path (wl-draft-get-folder)))
-        (filename
-         (expand-file-name
-          (format "%s-%d" wl-draft-config-save-filename msg)
-          msgdb-dir))
+        (filename (wl-draft-config-info-filename msg msgdb-dir))
         element alist variable)
     (cond
      ((eq operation 'save)
@@ -2638,6 +2640,20 @@ been implemented yet.  Partial support for SWITCH-FUNCTION now supported."
     (setq wl-draft-parent-flag flag)
     (wl-draft-config-info-operation wl-draft-buffer-message-number 'save)))
 
+(defun wl-draft-buffer-change-number (old-number new-number)
+  (when (eq wl-draft-buffer-message-number old-number)
+    (setq wl-draft-buffer-message-number new-number)
+    (rename-buffer (format "%s/%d" wl-draft-folder new-number))
+    (setq buffer-file-name (buffer-name))
+    (set-buffer-modified-p nil)))
+
+(defun wl-draft-rename-saved-config (old-number new-number)
+  (let* ((msgdb-dir (elmo-folder-msgdb-path (wl-draft-get-folder)))
+        (old-name (wl-draft-config-info-filename old-number msgdb-dir))
+        (new-name (wl-draft-config-info-filename new-number msgdb-dir)))
+    (when (file-exists-p old-name)
+      (rename-file old-name new-name 'ok-if-already-exists))))
+
 (require 'product)
 (product-provide (provide 'wl-draft) (require 'wl-version))
 
index 6098d77..250b295 100644 (file)
--- a/wl/wl.el
+++ b/wl/wl.el
@@ -720,6 +720,18 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
        (nth 1 spec)))
     (setq elmo-no-from wl-summary-no-from-message)
     (setq elmo-no-subject wl-summary-no-subject-message)
+    (elmo-connect-signal
+     nil
+     'message-number-changed
+     'wl-draft
+     (elmo-define-signal-handler (listener folder old-number new-number)
+       (dolist (buffer (wl-collect-draft))
+        (with-current-buffer buffer
+          (wl-draft-buffer-change-number old-number new-number)))
+       (wl-draft-rename-saved-config old-number new-number))
+     (elmo-define-signal-filter (listener folder old-number new-number)
+       (and folder
+           (string= (elmo-folder-name-internal folder) wl-draft-folder))))
     (wl-news-check)
     (setq wl-init t)
     ;; This hook may contain the functions `wl-plugged-init-icons' and
@@ -929,7 +941,8 @@ If ARG (prefix argument) is specified, folder checkings are skipped."
       wl-score-change-score-file wl-score-edit-current-scores
       wl-score-edit-file wl-score-flush-cache wl-summary-rescore
       wl-score-set-mark-below wl-score-set-expunge-below
-      wl-summary-increase-score wl-summary-lower-score ))))
+      wl-summary-increase-score wl-summary-lower-score )
+     ("wl-draft" wl-draft-rename-saved-config))))
 
 ;; for backward compatibility
 (defalias 'wl-summary-from-func-petname 'wl-summary-default-from)