mu4e-compose: improve mu4e-message-kill-buffer

Try to go back to the buffer we were in before. HT: @thierryvolpiatto

Fixes #2600.
This commit is contained in:
Dirk-Jan C. Binnema
2023-11-30 21:33:02 +02:00
parent f3606c0352
commit 18efe9a955

View File

@ -458,15 +458,13 @@ appropriate flag at the message forwarded or replied-to."
It attempts to restore some mu4e window layout after killing the It attempts to restore some mu4e window layout after killing the
compose-buffer." compose-buffer."
(interactive) (interactive)
(let ((win (selected-window)) (let ((view (save-selected-window (mu4e-get-view-buffer)))
(view (mu4e-get-view-buffer))
(hdrs (mu4e-get-headers-buffer))) (hdrs (mu4e-get-headers-buffer)))
(message-kill-buffer) (message-kill-buffer)
(when (window-live-p win) (delete-window win)) ;; try to go back to some mu window if it is live; otherwise do nothing.
;; try to go back to some mu window if its live; otherwise do nothing. (if (buffer-live-p view)
(if (and (buffer-live-p view) (window-live-p (get-buffer-window view)))
(switch-to-buffer view) (switch-to-buffer view)
(when (and (buffer-live-p hdrs) (window-live-p (get-buffer-window hdrs))) (when (and (buffer-live-p hdrs))
(switch-to-buffer hdrs))))) (switch-to-buffer hdrs)))))
;;; Crypto ;;; Crypto