How do I prevent org-mode from executing all of the babel source blocks?
The variable org-export-babel-evaluate
, if set to nil
, will prevent any code from being evaluated as part of the export process. This way, only the results inserted by way of manual execution will be exported.
You can define it, and others, as a file variable by placing the following comment line at the top of your org file:
# -*- org-export-babel-evaluate: nil -*-
Setting the variable org-export-babel-evaluate to nil will avoid code evaluation, but it will also cause all source block header arguments to be ignored This means that code blocks with the argument :exports none
or :exports results
will end up in the export. This caught me off guard.
The alternative is to use the header argument :eval never-export
on a file basis and then remove that line when re-running the source code:
#+PROPERTY: header-args :eval never-export
See the docstring for org-babel-evaluate:
Switch controlling code evaluation and header processing during export. When set to nil no code will be evaluated as part of the export process and no header arguments will be obeyed. Users who wish to avoid evaluating code on export should use the header argument ‘:eval never-export’.
You can set the cache
to yes (see http://orgmode.org/manual/cache.html). This can also be set a property line in the file to act globally.
#+Property: header-args :cache yes
just make sure to C-c C-c
on that line to activate the property.
After placing the following:
# -*- org-export-use-babel: nil;-*-
at the top of the file, and executing C-c C-c, It didn't work for me. The variable's value is not set accordingly.
But the following:
#+BIND: org-export-use-babel nil
with an application of C-c C-c works as expected.
I found the answer here: http://joelmccracken.github.io/entries/org-mode-specifying-document-variables-and-keywords/
There are probably some changes in emacs 26, which I'm using.