mu4e: restore window-layout after `message-kill-buffer'

Replaces `message-kill-buffer' with `mu4e-message-kill-buffer'. This new
function is a wrapper around the original. It restores the window-layout
of mu4e after cancelling a message in mu4e-compose-mode.
This commit is contained in:
Lukas Fürmetz 2016-02-01 21:33:18 +01:00 committed by djcb
parent 41948ef8e4
commit 46ca26457a
1 changed files with 19 additions and 0 deletions

View File

@ -314,6 +314,7 @@ message-thread by removing the In-Reply-To header."
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-S-u") 'mu4e-update-mail-and-index) (define-key map (kbd "C-S-u") 'mu4e-update-mail-and-index)
(define-key map (kbd "C-c C-u") 'mu4e-update-mail-and-index) (define-key map (kbd "C-c C-u") 'mu4e-update-mail-and-index)
(define-key map (kbd "C-c C-k") 'mu4e-message-kill-buffer)
map))) map)))
(defvar mu4e-compose-mode-abbrev-table nil) (defvar mu4e-compose-mode-abbrev-table nil)
@ -472,6 +473,24 @@ the appropriate flag at the message forwarded or replied-to."
(when (fboundp 'mu4e) (mu4e)))) (when (fboundp 'mu4e) (mu4e))))
(mu4e-message "Message sent")) (mu4e-message "Message sent"))
(defun mu4e-message-kill-buffer ()
"Wrapper around `message-kill-buffer'.
It restores mu4e window layout after killing the compose-buffer."
(interactive)
(let ((current-buffer (current-buffer)))
(message-kill-buffer)
;; Compose buffer killed
(when (not (equal current-buffer (current-buffer)))
;; Restore mu4e
(if mu4e-compose-in-new-frame
(delete-frame)
(if (buffer-live-p mu4e~view-buffer)
(switch-to-buffer mu4e~view-buffer)
(if (buffer-live-p mu4e~headers-buffer)
(switch-to-buffer mu4e~headers-buffer)
;; if all else fails, back to the main view
(when (fboundp 'mu4e) (mu4e))))))))
(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
'passed' \"F\" flag on message we have forwarded. 'passed' \"F\" flag on message we have forwarded.