* mu4e-compose.el: clean up draft buffers after message sending

This commit is contained in:
djcb
2012-06-14 09:57:47 +03:00
parent 245de14b1d
commit c9948d5072

View File

@ -463,14 +463,12 @@ needed, set the Fcc header, and register the handler function."
(set-buffer-modified-p t) (set-buffer-modified-p t)
(save-buffer) (save-buffer)
(mu4e~setup-fcc-maybe)) nil t) (mu4e~setup-fcc-maybe)) nil t)
;; when the message has been sent. ;; when the message has been sent.
(add-hook 'message-sent-hook (add-hook 'message-sent-hook
(lambda () (lambda ()
(setq mu4e-sent-func 'mu4e-sent-handler) (setq mu4e-sent-func 'mu4e-sent-handler)
(mu4e~proc-sent (buffer-file-name) mu4e-drafts-folder)) nil))) (mu4e~proc-sent (buffer-file-name) mu4e-drafts-folder)) nil)))
(defconst mu4e~compose-buffer-max-name-length 30 (defconst mu4e~compose-buffer-max-name-length 30
"Maximum length of the mu4e-send-buffer-name.") "Maximum length of the mu4e-send-buffer-name.")
@ -568,7 +566,14 @@ message. For Forwarded ('Passed') and Replied messages, try to set
the appropriate flag at the message forwarded or replied-to." the appropriate flag at the message forwarded or replied-to."
(mu4e~compose-set-parent-flag path) (mu4e~compose-set-parent-flag path)
(when (file-exists-p path) ;; maybe the draft was not saved at all (when (file-exists-p path) ;; maybe the draft was not saved at all
(mu4e~proc-remove docid))) (mu4e~proc-remove docid))
;; kill any remaining buffers for the draft file, or they will hang around...
;; this seems a bit hamfisted...
(dolist (buf (buffer-list))
(when (and (buffer-file-name buf)
(string= (buffer-file-name buf) path))
(kill-buffer buf)))
(mu4e-message "Message sent"))
(defun mu4e~compose-set-parent-flag (path) (defun mu4e~compose-set-parent-flag (path)
"Set the 'replied' \"R\" flag on messages we replied to, and the "Set the 'replied' \"R\" flag on messages we replied to, and the
@ -706,8 +711,5 @@ message."
'message-kill-buffer 'message-kill-buffer
'message-send-hook) 'message-send-hook)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'mu4e-compose) (provide 'mu4e-compose)