0

I'm often working with org-mode 'externally' these days. I.e., I edit org-mode files with Emacs, but then export the files using Makefiles to various other formats by using rules such as:

%.tex : %.org
        $(EMACS) --batch --visit=$< --eval='(progn (setq org-confirm-babel-evaluate nil)(org-latex-export-to-latex))'
%.html: %.org
        $(EMACS) --quick --visit=$< --eval='(progn (setq org-confirm-babel-evaluate nil)(org-html-export-to-html)(kill-emacs))'

This works just fine, however at some point I wanted to 'extend' this slightly with some special setting (omitted in this case), and consequently use a different output path:

%.conf.html: %.org
        $(EMACS) --quick --visit=$< --eval='(progn (setq org-confirm-babel-evaluate nil)(org-html-export-to-html)(kill-emacs))'

The problem is that I cannot seem to control the output path of the org-mode export commands as by default they only use the buffer-file-name. The "closest" options I have found is the setting #+EXPORT_FILE_NAME: <file> in the header. However, I would like to change this without editing the file, i.e., "externally". Is this possible somehow?

(I suppose that creating a temporary file in the same directory might work, but there may be subtle issues with that, something I'm hoping to avoid.)

1
  • I don't think you can "set" EXPORT_FILE_NAME externally (at least my cursory reading of the code has not uncovered such a method). The answer below is probably the best way to go, particularly since you are foregoing interactivity anyway.
    – NickD
    Jun 8, 2023 at 17:24

1 Answer 1

2

org-html-export-to-html calls org-export-to-file

Manually calling (org-export-to-file 'html "~/toto.html") exports to the given file. So you can extend this to work with your makefile.

1
  • This works great! I only changed it slightly by using (org-export-to-file (quote html) "$@") to avoid quoting problems in the shell and to use the automatic Makefile variables
    – Xaldew
    Jun 13, 2023 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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