1

I am trying to write some org-mode text (a bulleted list in this case), and then reuse it at several points in my document when exporting.

I managed to get this working by putting my text inside a source block which babel then evaluates for me, and inserting the result using #+call: lines. (If there is a better way to approach this problem, please let me know!)

I can get the desired result using ruby, but not using emacs-lisp, which inserts quotes and escape characters in my output.

Can anyone help me get this working with emacs-lisp? (I figured emacs-lisp is the best option since it is native to the emacs / org-mode stack, not some external interpreter that has to run, like ruby)

Below is my org mode doc with working ruby setup and failed emacs-lisp attempts, and below that is the output from export to plain text.

This is my Org Mode doc

* Testing export with ruby (is doing what I want)
#+name: generate_text_ruby
#+begin_src ruby :results output verbatim raw
puts %q{+ this is bullet 1
+ and this is bullet two}
#+end_src

This should be followed by two lines of text:
#+call: generate_text_ruby()

This should also be followed by the same two lines:
#+call: generate_text_ruby()

* Testing export with elisp (not doing what I want)
#+name: generate_text_elisp
#+begin_src emacs-lisp :results value verbatim raw
(format "+ This is bullet one,
+ and this is bullet two")
#+end_src

This should be followed by two lines of text:
#+call: generate_text_elisp()

This should also be followed by the same two lines:
#+call: generate_text_elisp()

* I also tried with print
#+name: generate_text_elisp2
#+begin_src emacs-lisp :results output verbatim raw
(print "+ This is bullet one,
+ and this is bullet two")
#+end_src

This should be followed by two lines of text:
#+call: generate_text_elisp2()

This should also be followed by the same two lines:
#+call: generate_text_elisp2()

This is the output from export to plain text:

1 Testing export with ruby (is doing what I want)
=================================================

  ,----
  | puts %q{+ this is bullet 1
  | + and this is bullet two}
  `----

  This should be followed by two lines of text:
  + this is bullet 1
  + and this is bullet two

  This should also be followed by the same two lines:
  + this is bullet 1
  + and this is bullet two


2 Testing export with elisp (not doing what I want)
===================================================

  ,----
  | (format "+ This is bullet one,
  | + and this is bullet two")
  `----

  This should be followed by two lines of text:
  "+ This is bullet one,
  + and this is bullet two"

  This should also be followed by the same two lines:
  "+ This is bullet one,
  + and this is bullet two"


3 I also tried with print
=========================

  ,----
  | (print "+ This is bullet one,
  | + and this is bullet two")
  `----

  This should be followed by two lines of text:
  " \"+ This is bullet one,
  + and this is bullet two\"
  "

  This should also be followed by the same two lines:
  " \"+ This is bullet one,
  + and this is bullet two\"
  "
1

You probably want the value of the last statement, not the stdout as is returned by :results output. Since :results value is the default for Elisp blocks, you're good to go with :results raw.

#+begin_src emacs-lisp :results raw
"+ This is bullet one,
+ and this is bullet two"
#+end_src

Another option that may be of interest is the following:

#+begin_src emacs-lisp :results list
(list "This is bullet one," "and this is bullet two")
#+end_src

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.