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")

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.


1 Answer 1


The code blocks don't get evaluated unless you specifically tell Org mode to do it (or do C-h i g (org)Evaluating Code Blocks in Emacs). 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. (or do C-h i g (org)Working with Source Code in Emacs)

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")
#+call: test()

# Local Variables:
# org-confirm-babel-evaluate: (lambda (lang body) (not (string= lang "emacs-lisp")))
# End:
  • 3
    What exactly is the "Local Variable" code doing again? What is it for?
    – 147pm
    Nov 10, 2015 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, 2018 at 2:51
  • The links are expired. Also, is the default behaviour changed now? Because when I export an org file it always evaluate my code blocks. Apr 15, 2022 at 17:23
  • 1
    @Atreyagaurav I have fixed the links and also suggested a better way of accessing the Org manual from within Emacs using the C-h i g .. (default) bindings. Apr 15, 2022 at 21:06

Your Answer

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

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