2

I want to manipulate an org mode source block that is referenced with noweb in an eLisp source block:

#+name: conceptmap
#+begin_src org :results value raw :exports results
(ONE) {TWO} (THREE)
(FOUR) {FIVE} (SIX)
#+end_src

#+begin_src emacs-lisp :noweb yes :results output 
(downcase (<<conceptmap()>>)
#+end_src

The desired result is:

(one) {two} (three)
(four) {five} (six)

The actual result is:

(downcase ((ONE) {TWO} (THREE)
(downcase ((FOUR) {FIVE} (SIX))

Why is it that the function downcase is not executed, and why is it that it is repeated? What is <<conceptmap()>> in reality? Can it be treated like a string or text block?

  • Have you settled on noweb for some reason that is not to be seen in your MWE? Otherwise you can refer to the org block's content with :var str=conceptmap in the header, change the results type to st. like value and evaluate (downcase str). – mutbuerger Jul 2 '16 at 16:33
  • Thanks, @mutbuerger. I have settled with your suggestion. If you nonetheless know an answer to my question, I'd be interested as the noweb approach looks promising. – Singulaere Entitaet Jul 3 '16 at 13:23
2

I found the solution to your problem.

Your file should look like this

#+name: conceptmap
#+begin_src org  :exports none
 (ONE) {TWO} (THREE) 
 (FOUR) {FIVE} (SIX)
#+end_src

#+begin_src emacs-lisp :noweb yes 
  (downcase "
    <<conceptmap2>>
   "
  )
#+end_src

Pay close attention to the ", as your original "input" would be parsed directly and strings like (ONE) would be interpreted as functions.

Another extremely important point is that the noweb reference must be on its own line as it seems there is either a bug, or an underdocumented limitation on the noweb expansion algorithm (I have no idea if the limitation is woth fixing )

I have a little example of what happens if the noweb reference is in its own line.

 #+name: test
 #+BEGIN_SRC emacs-lisp
  (let ((a 1)
        (b 2)
        (c 3))
    (+ a b c))
#+END_SRC

#+BEGIN_SRC emacs-lisp :noweb yes
  (+ 4 <<test>>)
#+END_SRC

which get expanded as

(+ 4 (let ((a 1)
(+ 4       (b 2)
(+ 4       (c 3))
(+ 4   (+ a b c)))

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.