From a0f0e9534423f22cd2d074e5f89b3bea2bdbe862 Mon Sep 17 00:00:00 2001 From: djcb Date: Sat, 20 Feb 2016 12:25:21 +0200 Subject: [PATCH] mu4e: better handling of closing compose frames Use message-mode actions to close the compose frame (`mu4e-compose-in-new-frame') whenever we're finished editing a message. --- mu4e/mu4e-compose.el | 19 +++++++++---------- mu4e/mu4e-draft.el | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index b7e19942..41fa8416 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -438,7 +438,14 @@ tempfile)." ;; hide some headers (mu4e~compose-hide-headers) ;; switch on the mode - (mu4e-compose-mode)) + (mu4e-compose-mode) + (when mu4e-compose-in-new-frame + ;; make sure to close the frame when we're done with + ;; the message + ;; these are all buffer-local; + (push 'delete-frame message-exit-actions) + (push 'delete-frame message-kill-actions) + (push 'delete-frame message-postpone-actions))) (defun mu4e-sent-handler (docid path) "Handler function, called with DOCID and PATH for the just-sent @@ -452,16 +459,8 @@ the appropriate flag at the message forwarded or replied-to." (dolist (buf (buffer-list)) (when (and (buffer-file-name buf) (string= (buffer-file-name buf) path)) - (if (and mu4e-compose-in-new-frame (window-system)) - (progn - (switch-to-buffer buf) - (when (and (get-buffer-window buf) - (window-frame (get-buffer-window buf))) - (delete-frame (window-frame (get-buffer-window buf))))) - ) (if message-kill-buffer-on-exit - (kill-buffer buf)) - )) + (kill-buffer buf)))) ;; now, try to go back to some previous buffer, in the order ;; view->headers->main (if (buffer-live-p mu4e~view-buffer) diff --git a/mu4e/mu4e-draft.el b/mu4e/mu4e-draft.el index 1158d1d7..b884c090 100644 --- a/mu4e/mu4e-draft.el +++ b/mu4e/mu4e-draft.el @@ -404,7 +404,7 @@ fields will be the same as in the original." (defun mu4e~draft-open-file (path) "Open the the draft file at PATH." - (if (and mu4e-compose-in-new-frame (window-system)) + (if mu4e-compose-in-new-frame (find-file-other-frame path) (find-file path)))