I'm trying go get the src block contents with (org-element-property :value (org-element-at-point)), but when I apply this on a block like:

#+BEGIN_SRC emacs-lisp
(print "foo")

the result is (print \"foo\"). How can I get the exact contents from the block as a string ?

  • 2
    Is it possible you are getting the exact contents and (print \"foo\") is how emacs displays it? (since "(print "foo" )" is two different strings with the word foo in between). Is it that you want to print the exact contents (print "foo") out to the buffer? Apr 8 '18 at 18:33
  • Yeah, you're right. I should have taken another look at it before asking. It's actually not about printing. My problem is solved. Thanks!
    – bertfred
    Apr 8 '18 at 19:14
  • FWIW, it returns "(print \"foo\")\n" from here with Org 9.1.9. Note that \n might be rendered when print-escape-newlines is nil.
    – xuchunyang
    Apr 9 '18 at 4:33

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.