What command-line arguments do I use to get Emacs to export an org-mode file to a Beamer PDF? (I want to create a Makefile
that produces a PDF when the user runs make
.)
I tried following this answer but couldn't get it to work:
$ emacs --batch foo.org -f org-beamer-export-to-pdf
Symbol's function definition is void: org-beamer-export-to-pdf
$ emacs --batch -l ox-beamer foo.org -f org-beamer-export-to-pdf
Cannot open load file: ox-beamer
The above error comes from the fact that the org-mode files are in a custom location and my ~/.emacs.d/init.el
is not loaded (--batch
implies -q
a.k.a. --no-init-file
).
If I tell Emacs to load my init file it will work:
$ emacs --batch -l ~/.emacs.d/init.el foo.org -f org-beamer-export-to-pdf
However, this doesn't work for other users that use ~/.emacs
or ~/.emacs.el
instead of ~/.emacs.d/init.el
. I tried telling Emacs to load user-init-file
but it didn't work:
$ emacs --batch --eval '(load user-init-file)' foo.org -f org-beamer-export-to-pdf
Wrong type argument: stringp, nil
Assuming all users can successfully press C-x C-e l P
to export a Beamer PDF when using Emacs interactively, what non-interactive command will produce a PDF?
(require 'org)
or something like that – your init file is doing some loading that--batch
is prohibiting.emacs -u $USER --batch --eval '(message "-----> My user-init-file: "%s" user-init-file)'
. If you don't load your init file, you probably need to requireox-beamer
.