1

The org-export-dispatch command in org-mode (C-c C-e) brings up an UI from which one can, e.g. select l and l to export the .org file to latex format.

My question is:

Can one use elisp to fix the input to l and l programmatically in order to get the exported (latex) file without any keyboard interaction?

If so, what would the expression/command be?

This is with Emacs 26 under Ubuntu 20.04. I read this article but just don't know elisp enough to understand its workings.

3

Unless you spend your days exporting org documents I'd stick to the export interface because it's mature and takes care of the little details.

If you still want something to bind to a single key, a very minimal implementation of it could be:

(defun my/to-latex-file()
  (interactive)
  (org-export-to-file 'latex (read-from-minibuffer "Filename for latex file: ")))

Note that it won't test if the filename you choose already exists or anything.

This snippet will use original file path/name to automatically use the same with .tex extension, still, it won't care about any previous file:

(defun my/to-latex-file()
  (interactive)
  (let ((filename (buffer-file-name)))
    (setq  filename (replace-regexp-in-string "\.org\$" "\.tex" filename)) 
    (org-export-to-file 'latex filename)))

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.