aboutsummaryrefslogtreecommitdiff
path: root/docs/mu4e-org-msg-compose-buffer-cleanup.org
blob: a6ea361febef26ff2b3a6d0bae95baadba20d368 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#+TITLE: Closing mu4e / org-msg Compose Buffers on Exit
#+AUTHOR: Craig Jennings
#+DATE: 2026-05-23

* What this controls

Whether a mail compose buffer is killed when the message is sent or
the compose is aborted, versus left behind for you to deal with.  The
single knob is the built-in message-mode variable:

: message-kill-buffer-on-exit

- =t=   — kill the compose buffer on send / abort (no leftover buffers).
- =nil= — keep the compose buffer after exit.

* The one place to set it

Set it once, in the =mu4e= =:config= block in =modules/mail-config.el=:

#+begin_src emacs-lisp
(setq message-kill-buffer-on-exit t)
#+end_src

That single setting governs *both* plain mu4e compose buffers and
org-msg (HTML) compose buffers.  There is no need to set it anywhere
else.

* Why org-msg doesn't need its own setting

org-msg-mode is the active composer in every compose buffer (the config
runs =(org-msg-mode +1)=), so it's natural to assume org-msg needs its
own copy of the policy.  It does not.

org-msg only *reads* =message-kill-buffer-on-exit= — it never sets it.
The single read is in =org-msg--widen-and-undo= (org-msg.el): when the
value is =nil= (buffer will survive), org-msg widens and undoes its edits
so the leftover buffer is clean; when the value is =t= (buffer will be
killed), it skips that work because the buffer is about to go away.

So whatever value the mu4e =:config= leaves in place is the value org-msg
honors.

* The trap to avoid

A =(setq message-kill-buffer-on-exit ...)= inside the *org-msg* =:config=
block silently wins over the mu4e one, because org-msg's =use-package=
form loads after mu4e's and its =:config= runs later.  An older version
of this config set =t= in mu4e and =nil= in org-msg, so compose buffers
were always kept — the mu4e setting looked authoritative but was dead.

Keep this policy in a single place (mu4e) so the effective value is
obvious.  If you ever want to keep compose buffers again, flip the one
setting to =nil=; don't reintroduce a second setter in org-msg.

* Quick reference

| Goal                          | Setting                                 |
|-------------------------------+-----------------------------------------|
| Kill compose buffers on exit  | =(setq message-kill-buffer-on-exit t)=   |
| Keep compose buffers on exit  | =(setq message-kill-buffer-on-exit nil)= |

Set it in the mu4e =:config= block of =modules/mail-config.el=, and
nowhere else.