Org Mode's Babel for executing code blocks provides two header arguments, :output-dir and :file-ext that were clearly intended to be used in the global document header, applying to all blocks. They enable Org to auto-generate the names of files that are produced by the blocks - most commonly, I guess, graphics.

This works fine for graphics blocks, as intended. They allow easy switching between graphics formats. However, it also seems to mean that ALL blocks now save their results in a file, even where this is not appropriate (e.g. the block calculates a single value, which should be inserted directly into the document).

Am I missing something, or is this just a limitation, that these useful global arguments can't be used if a document happens to produce a mixture of tables and charts?

#+TITLE: Don't export EVERYTHING as a pdf
#+PROPERTY: header-args:R  :output-dir charts :file-ext pdf

The :output-dir and :file specify the directory and file extension that should be used to save output of all blocks. However, this results in ALL blocks' output being saved to files, even where this is not appropriate.

#+NAME: code_that_should_output_a_value
#+BEGIN_SRC R :exports results :results value 
dat <- data.frame( a=1:3, b=10:12)

#+RESULTS: code_that_should_output_a_value

Update: I asked on the mailing list: http://lists.gnu.org/archive/html/emacs-orgmode/2018-05/msg00466.html What emerged:

  • setting :file-ext indeed sets :results file for all blocks. So if it's used as a global header, all blocks will be forced to output files, whether wanted or not.
  • :file-ext was originally envisioned for use at block level - to automatically generate file names in combination with #+NAME: and possibly :output-dir.
  • The current behaviour is not seen as ideal, and may well be changed in Org 10.0 (but not straight away, to maintain backwards compatibility with existing documents)

1 Answer 1


The default Org Babel behaviour is to automatically determine the output type of your source blocks.

When using the :file-ext, Org mode will automatically assume that you are saving outputs to a file, and that is what you'll get unless you overwrite the :results setting - either in your source block, or a more local PROPERTY (i.e., heading specific).

Now, I see that you already tried to overwrite the setting by writing :results value, but what Org Mode is actually seeing is :results value file. That is because :results encompasses 4 different classes of header arguments: Collection, Type, Format and Handling.

You can check what Org sees by placing the cursor on top of the #+BEGIN_SRC line and looking at the echo area.

To correctly remove the "file" from :results you have to choose another output Type from the ones listed here. Try, for example:

#+NAME: code_that_should_output_a_value
#+BEGIN_SRC R :exports results :results value scalar
dat <- data.frame( a=1:3, b=10:12)
  • Thank you for the answer and the explanation, which makes sense (even if I find the undocumented side-effect of :file-ext changing the :results not to my taste). But putting my mark at the beginning of the code block doesn't echo anything, and adding :results value scalar (or verbatim) still writes to a file and inserts a file link. Did you try it - does it work? I have Org 9.1.13 May 24, 2018 at 14:45
  • You are right, sorry that I wrote without testing. I also get the file link, although the behaviour should've been changed when changing the Type. Try reporting this in the Org Mode mailing list. They are usually quite fast at answering. Meanwhile I'll see if I can get it to work
    – Daniel
    May 24, 2018 at 15:01
  • OK thanks for testing it out. I'll get in touch with the mailing list May 24, 2018 at 19:16

Your Answer

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

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