7

I have some sort of fundamental confusion about using src blocks in org mode.

I define a custom latex class in an emacs-lisp src block at the top of my org file. Export fails however, unless I manually execute the src block (because the required latex class doesn't exist until the src block is executed). I'm not prompted for permission to execute the block.

As a minimal example, I tried exporting this:

#+name: test
#+begin_src emacs-lisp
(message "Success")
#+end_src

On export, I see org-babel-exp processing... in my messages buffer, and I would expect to see "Success" immediately after it, but I don't.

I'm clearly missing something obvious, but it's not clear to me from the info what I should be doing.

6

The code blocks don't get evaluated unless you specifically tell org-mode to do it. The snippet in your example will simply export to a code block in your chosen export format: pdf, html, etc.

More on org-mode and source blocks.

Here is the modified version of your example with the required #+CALL: line and the good to have buffer local variable declaration to mark the execution of emacs-lisp snippets as safe.

#+NAME: test
#+BEGIN_SRC emacs-lisp
(message "Success")
#+END_SRC

#+CALL: test()

# Local Variables:
# org-confirm-babel-evaluate: (lambda (lang body) (not (string= lang "emacs-lisp")))
# End:
  • 2
    What exactly is the "Local Variable" code doing again? What is it for? – 147pm Nov 10 '15 at 19:16
  • @147pm - The local variable allows the emacs-lisp source block to execute during the export without prompting the user for confirmation. To disable confirmation for all languages, do org-confirm-babel-evaluate: nil instead. – Melioratus May 27 '18 at 2:51

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.