org-msg
org-msg copied to clipboard
Unwanted *ORG ASCII Export* buffer
Hi,
Every time that I compose a message withorg-msg
enabled, a new buffer called *Org ASCII Export*
of my email is generated. I am feeling that I am doing something wrong. Can anyone point what I am doing wrong?
Emacs 28.2 Org-mode version 9.6.6 Org-msg config:
(use-package org-msg
:after (mu4e org)
:config
(org-msg-mode)
:custom
(org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil email:nil tex:dvipng \\n:t")
(org-msg-startup "inlineimages")
(org-msg-greeting-fmt "\nHi%s,\n\n")
(org-msg-default-alternatives '((new . (text html))
(reply-to-html . (text html))
(reply-to-text . (text))))
(org-msg-greeting-name-limit 3)
)
Thanks, Kourosh
I have the same; this is an org-mode behaviour, see the docstring for org-export-show-temporary-export-buffer
. To keep that buffer buried, you can add this to your .emacs
:
(setq org-export-show-temporary-export-buffer nil)
The buffer is still there, but it remains buried. When I reply/forward to a message that I view, it also remains visible after sending, whereas most mua would close that message. To remove these buffers, I add the following to .emacs
(if you use another mua than mu4e you may not have that second issue):
(setq org-export-show-temporary-export-buffer nil)
(add-hook 'message-sent-hook '(lambda()
(interactive)
(switch-to-buffer "*mu4e-article*")
(mu4e-view-quit)
(kill-buffer "*Org ASCII Export*")))
@prbuen Thanks for pointing out org-export-show-temporary-export-buffer
. I figured it was built-in org behavior but I couldn't pinpoint an option for it.
This is the clever snippet I use for it to only affect org-msg export buffers:
(defun org-msg-no-temp-buffer (orig-fun &rest args)
"Advice to set `org-export-show-temporary-export-buffer' to `nil'."
(let ((org-export-show-temporary-export-buffer nil))
(apply orig-fun args)))
(advice-add 'org-msg-preview :around #'org-msg-no-temp-buffer)
(advice-add 'org-msg-ctrl-c-ctrl-c :around #'org-msg-no-temp-buffer)
The snippet you mentioned can be added after the apply
call, too.
EDIT: The above snippet actually didn't work as well as I though it would (I got hasty typing the message before testing). The issue was with the window configuration not being desirable after sending an email. With some tinkering, I found that the neatest solution is this:
(add-hook 'message-sent-hook
#'(lambda ()
(when (bound-and-true-p org-msg-mode)
(switch-to-buffer "*Org ASCII Export*")
(kill-buffer-and-window))))
This returns the window configuration to how it was prior to email composition, regardless of where the user began email composition. Perhaps this doesn't work fully with different display-buffer-alist
configurations, but for my Emacs config this works perfectly.
Thanks @prbuen and @krisbalintona. I combined your solutions and it is working nicely.
@kourosh2 would you mind sharing what worked for you? Currently trying to sort this out myself, I think that I use frames-only-mode is adding another variable here.
@kourosh2 would you mind sharing what worked for you? Currently trying to sort this out myself, I think that I use frames-only-mode is adding another variable here.
Sure, see below:
(use-package org-msg
:preface
(defun org-msg-no-temp-buffer (orig-fun &rest args)
"Advice to set `org-export-show-temporary-export-buffer' to `nil'."
(let ((org-export-show-temporary-export-buffer nil))
(apply orig-fun args)))
:config
(advice-add 'org-msg-preview :around #'org-msg-no-temp-buffer)
(advice-add 'org-msg-ctrl-c-ctrl-c :around #'org-msg-no-temp-buffer)
(add-hook 'message-sent-hook
(lambda ()
(interactive)
(switch-to-buffer "*mu4e-article*")
(mu4e-view-quit)
(kill-buffer "*Org ASCII Export*"))))