1

What is the simplest way to configure org-mode to automatically open the exported file as soon as org-export-dispatch succeeds?

  • I don't understand the question: every export dispatch command allows you to export to a buffer, export to a file or export to a file and open the resulting file. Isn't this last option enough for your purposes? If not, why not? If you have additional requirements, please edit the question and add them. – NickD Apr 24 '18 at 2:06
0

I interpret your request to be to open-and-display the exported file. Also, you don't provide a particular use-case, so I have assumed use of `org-publish-project'. Our goal can be achieved using defadvice.

Your request appears to be an anti-goal of org-mode. The docstring for `org-export-show-temporary-export-buffer' says

When Org exports to a file, the buffer visiting that file is never
shown, but remains buried.

In the default code-path for org-publish-project', the special formsave-excursion' is called which will revert any change to the display. That means that we need to switch buffers there.

The following achieves our goal:

(defadvice org-export-to-file (after open-file activate)
  ;;; Need to save the buffer name for later...
  (setq realraptor/org-project-buffer (find-file-noselect file t)))  

(defadvice org-publish-project (after open-file activate)
  (message "Advice on org-export-project called")
  (switch-to-buffer realraptor/org-project-buffer)) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.