mu4e-compose: attempt to delete frame after done with composition

Attempt to delete the frame when
a) it's not the last frame, and
b) there's only a single window on the frame

Fixes #2577
This commit is contained in:
Dirk-Jan C. Binnema 2023-12-04 19:25:55 +02:00
parent 730bd13ea2
commit 526d49f70c
1 changed files with 12 additions and 3 deletions

View File

@ -744,11 +744,15 @@ Is this address yours?"
(if (not (message-field-value "Subject"))
(message-goto-subject)
(message-goto-body)))
;; buffer is not user-modified yet
(set-buffer-modified-p nil)
(undo-boundary))
(defun mu4e--maybe-delete-frame ()
"Delete frame if there are multiple and current one has a single window."
(when (and (one-window-p) (> (length (frame-list)) 1))
(delete-frame)))
(defun mu4e--compose-setup (compose-type compose-func &optional switch)
"Set up a new buffer for mu4e message composition.
@ -764,10 +768,11 @@ Optionally, SWITCH determines how to find a buffer for the message
(cl-assert (member compose-type '(reply forward edit new)))
(unless (mu4e-running-p) (mu4e 'background)) ;; start if needed
(let* ((parent
(when (member compose-type '(reply forward edit))
(mu4e-message-at-point)))
(when (member compose-type '(reply forward edit))
(mu4e-message-at-point)))
(mu4e-compose-parent-message parent)
(mu4e-compose-type compose-type)
(actions '(mu4e--maybe-delete-frame))
(buf))
(advice-add 'message-is-yours-p :around #'mu4e--message-is-yours-p)
(run-hooks 'mu4e-compose-pre-hook) ;; run the pre-hook. Still useful?
@ -779,6 +784,10 @@ Optionally, SWITCH determines how to find a buffer for the message
(set-visited-file-name ;; make it a draft file
(mu4e--draft-message-path (mu4e--message-basename) parent)))
(mu4e--compose-setup-post compose-type parent)
;; handle closing of frames.
(setq-local ;;message-kill-actions actions
message-postpone-actions actions
message-send-actions actions)
(setq buf (current-buffer)))
(switch-to-buffer buf)))