From: yoichi Date: Mon, 7 Mar 2005 12:04:36 +0000 (+0000) Subject: * elmo.el (message-number-changed): Define new signal. X-Git-Tag: wl-2_14-root~7 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0dac9c487619d807c889d71e936329d8eafee44;p=elisp%2Fwanderlust.git * 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'. * 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. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index ba7bcc8..6bd339a 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,12 @@ +2005-03-07 Yoichi NAKAYAMA + + * 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 * elmo-signal.el (elmo-connect-signal): Document. diff --git a/elmo/elmo-dop.el b/elmo/elmo-dop.el index 73d7fc6..33de027 100644 --- a/elmo/elmo-dop.el +++ b/elmo/elmo-dop.el @@ -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 diff --git a/elmo/elmo-localdir.el b/elmo/elmo-localdir.el index 82eeb4d..5a2ea59 100644 --- a/elmo/elmo-localdir.el +++ b/elmo/elmo-localdir.el @@ -355,6 +355,7 @@ (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))) diff --git a/elmo/elmo-map.el b/elmo/elmo-map.el index 08f23df..adac358 100644 --- a/elmo/elmo-map.el +++ b/elmo/elmo-map.el @@ -110,7 +110,10 @@ (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) @@ -126,6 +129,7 @@ (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)) diff --git a/elmo/elmo.el b/elmo/elmo.el index bc273b7..cd583f7 100644 --- a/elmo/elmo.el +++ b/elmo/elmo.el @@ -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") diff --git a/wl/ChangeLog b/wl/ChangeLog index c00cc2a..39eb120 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,12 @@ +2005-03-07 Yoichi NAKAYAMA + + * 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 * wl-summary.el (wl-summary-buffer-attach): Connect to signal diff --git a/wl/wl-draft.el b/wl/wl-draft.el index d5e6d9d..13ba443 100644 --- a/wl/wl-draft.el +++ b/wl/wl-draft.el @@ -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)) diff --git a/wl/wl.el b/wl/wl.el index 6098d77..250b295 100644 --- 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)