0

In my org-files I usually always enable pretty-printing at the top because I find it preferrable to Org's default of trying to fit output into tables and whatnot. But I have now hit a snag.

In a clean emacs -Q:

#+name: session-name
#+begin_src elisp
"The name of a session"
#+end_src

#+RESULTS: session-name
: "The name of a session"

#+begin_src elisp
(org-sbe session-name)
#+end_src
#+RESULTS:
: "\"The name of a session\""

The problem, as you can see, is that we end up with quotes in the value passed on to other code blocks.

Simply trying to supplant the header-arg :results with a code block local one does not help, which is wierd:

#+name: session-name-2
#+begin_src elisp :results value
"A second session"
#+end_src
#+RESULTS: session-name-2
: "A second session"

I have only found two ways around this issue:

  1. Remove the :results header block for the subtree

    ** A subtree
    #+PROPERTY: header-args :results value
    
    #+name: session-name-3
    #+begin_src elisp
    "A third session"
    #+end_src
    #+RESULTS: session-name-3
    : A third session
    

    But that has side effects like bash blocks resulting in their return code

    #+begin_src bash
    ls /
    #+end_src
    #+RESULTS:
    : 0
    
  2. Telling the org-mode to output the result in raw mode, which breaks reevaluation.

    #+name: session-name-4
    #+begin_src elisp :results raw
    "A fourth session"
    #+end_src
    #+RESULTS: session-name-4
    A fourth session
    
3
  • 1
    Did you try :results drawer instead of :results raw?
    – NickD
    Feb 22 at 22:43
  • No, that also works! Have you any idea why?
    – Rovanion
    Feb 27 at 16:20
  • See the Format section of Results of Evaluation in the manual.
    – NickD
    Feb 27 at 16:27

1 Answer 1

0

One workaround would be to explicitly only apply the pretty-printing to some languages like bash

#+PROPERTY: header-args:bash+ :results pp

#+name: session-name-5
#+begin_src elisp 
"A fifth session"
#+end_src
#+RESULTS: session-name-5
: A fifth session

#+begin_src elisp
(org-sbe session-name-5)
#+end_src
#+RESULTS:
: A fifth session


#+begin_src bash
ls /
#+end_src
#+RESULTS:
#+begin_example
bin
boot
...
#+end_example

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.