* wl-vars.el (wl-draft-kill-pre-hook): New hook.
authorteranisi <teranisi>
Tue, 31 Aug 2004 15:35:17 +0000 (15:35 +0000)
committerteranisi <teranisi>
Tue, 31 Aug 2004 15:35:17 +0000 (15:35 +0000)
(wl-draft-kill-flags): Fixed docstring.

* wl-draft.el (wl-draft-kill-flags): New function.
(wl-draft-kill): Run `wl-draft-kill-pre-hook'.

wl/ChangeLog
wl/wl-draft.el
wl/wl-vars.el

index 2ece5c4..6ca727d 100644 (file)
@@ -1,3 +1,11 @@
+2004-09-01  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * wl-vars.el (wl-draft-kill-pre-hook): New hook.
+       (wl-draft-kill-flags): Fixed docstring.
+
+       * wl-draft.el (wl-draft-kill-flags): New function.
+       (wl-draft-kill): Run `wl-draft-kill-pre-hook'.
+
 2004-08-31  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * wl-vars.el (wl-reply-hook): Abolish.
index f7253a2..fb7c054 100644 (file)
@@ -765,6 +765,24 @@ Reply to author if WITH-ARG is non-nil."
       (set-buffer-modified-p nil)              ; force kill
       (kill-buffer editing-buffer))))
 
+(defun wl-draft-kill-flags ()
+  "Remove flags on parent message when current draft is killed."
+  (let ((buffer (wl-summary-get-buffer wl-draft-parent-folder))
+       (number wl-draft-parent-number)
+       folder)
+    (if buffer
+       (with-current-buffer buffer
+         (dolist (flag wl-draft-kill-flags)
+           (wl-summary-unset-persistent-mark flag number)))
+      ;; Parent buffer does not exist.
+      (when (setq folder (and wl-draft-parent-folder
+                             (wl-folder-get-elmo-folder
+                              wl-draft-parent-folder)))
+       (elmo-folder-open folder 'load-msgdb)
+       (dolist (flag wl-draft-kill-flags)
+         (elmo-folder-unset-flag folder (list wl-draft-parent-number) flag))
+       (elmo-folder-close folder)))))
+
 (defun wl-draft-kill (&optional force-kill)
   "Kill current draft buffer and quit editing."
   (interactive "P")
@@ -774,24 +792,7 @@ Reply to author if WITH-ARG is non-nil."
               (or force-kill
                   (yes-or-no-p "Kill Current Draft? ")))
       (let ((cur-buf (current-buffer)))
-       (when (and wl-draft-parent-number
-                  (not (string= wl-draft-parent-folder "")))
-         (let* ((number wl-draft-parent-number)
-                (folder-name wl-draft-parent-folder)
-                (folder (wl-folder-get-elmo-folder folder-name))
-                buffer)
-           (if (and (setq buffer (wl-summary-get-buffer folder-name))
-                    (with-current-buffer buffer
-                      (string= (wl-summary-buffer-folder-name)
-                               folder-name)))
-               (with-current-buffer buffer
-                 (dolist (flag wl-draft-kill-flags)
-                   (elmo-folder-unset-flag folder (list number) flag))
-                 (when (wl-summary-jump-to-msg number)
-                   (wl-summary-update-persistent-mark)))
-             (elmo-folder-open folder 'load-msgdb)
-             (elmo-folder-unset-flag folder (list number) 'answered)
-             (elmo-folder-close folder))))
+       (run-hooks 'wl-draft-kill-pre-hook)
        (wl-draft-hide cur-buf)
        (wl-draft-delete cur-buf)))
     (message "")))
index 862a643..e24d8b6 100644 (file)
@@ -763,6 +763,9 @@ This hook runs on the draft buffer.")
   "A hook called when forwarded.
 This hook runs on the draft buffer.")
 
+(defvar wl-draft-kill-pre-hook '(wl-draft-kill-flags)
+  "A hook called just before the draft buffer is killed.")
+
 (defvar wl-summary-reply-hook
   '((lambda () (wl-summary-set-persistent-mark 'answered)))
   "A hook called when `wl-summary-reply' is called.
@@ -1780,7 +1783,7 @@ message buffer."
   :group 'wl-draft)
 
 (defcustom wl-draft-kill-flags '(answered)
-  "Remove specified flags when parent message of current draft is killed."
+  "Remove specified flags on parent message when current draft is killed."
   :type '(repeat (symbol :tag "flag"))
   :group 'wl-draft)