Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted *ORG ASCII Export* buffer #169

Open
kourosh2 opened this issue Jun 29, 2023 · 5 comments
Open

Unwanted *ORG ASCII Export* buffer #169

kourosh2 opened this issue Jun 29, 2023 · 5 comments

Comments

@kourosh2
Copy link

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

@prbuen
Copy link

prbuen commented Jul 8, 2023

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*")))

@krisbalintona
Copy link

krisbalintona commented Jul 10, 2023

@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.

@kourosh2
Copy link
Author

Thanks @prbuen and @krisbalintona. I combined your solutions and it is working nicely.

@podiki
Copy link
Contributor

podiki commented Oct 26, 2023

@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
Copy link
Author

@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*"))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants