I'm trying to extract a constant that is used by several blocks in my org-babel file.

#+name: myconst

Unfortunately it somehow adds a new line symbol to that string which breaks my other org-babel blocks which expect a "clean string".

Why it works this way? Is there a way to fix it?

Meanwhile, I'm using the following workaround:

#+name: myconst
#+begin_src emacs-lisp :results value
  • 1
    You can simplify the workaround by omitting the :results value - that's the default for elisp source blocks - and by getting rid of the quotes. I'm not sure why the newline is left in when you use the "bare" form, but I think there are numerous inconsistencies in Org mode (it grew "organically") and this may be one of them (OTOH, there may be a perfectly good reason for it - I just don't know). AFAIAC, your "workaround" is pretty much the canonical solution.
    – NickD
    Oct 25, 2021 at 16:51


Your Answer

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

Browse other questions tagged or ask your own question.