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

  • Great, can we remove the extra blank lines. – lucky1928 Feb 27 '17 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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