How do I prevent org-mode from executing all of the babel source blocks?

前端 未结 4 438
耶瑟儿~
耶瑟儿~ 2021-02-02 00:26

I have an org file with lots of babel source blocks in it that only need to be re-executed when the code is changed.

How do I prevent org from executing all of the block

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 01:08

    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’.

提交回复
热议问题