1

Org mode only print the last line into result block, can I get all print code into result block? for example:

#+BEGIN_SRC emacs-lisp
(setq my-list '(apple orange peach))
(print (car my-list))
(print (cdr my-list))
#+END_SRC

#+RESULTS:
| orange | peach |

Now it only capture the last print statement, I wish to capture:

#+RESULTS:
: apple
| orange | peach |

1 Answer 1

2

By default, code blocks return the value of the last statement in the block. In your example, this is the value returned by (print (cdr my-list)), which is the same as the value returned by (cdr my-list). You can use the :results flag to switch to output mode, where the output produced by your entire code block is returned:

#+BEGIN_SRC emacs-lisp :results output
(setq my-list '(apple orange peach))
(print (car my-list))
(print (cdr my-list))
#+END_SRC

#+RESULTS:
: 
: apple
: 
: (orange peach)

The various flags and their options are described in (org) Results of Evaluation

3
  • Great, can we remove the extra blank lines.
    – lucky1928
    Feb 27, 2017 at 4:31
  • At the time of writing this the proper link to the document describing org results options is here. Nov 14, 2022 at 12:51
  • @martinoidar thanks, I updated the link
    – Tyler
    Nov 14, 2022 at 15:36

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.