pnoulis · 2022-08-26 10:00
Hi,
I am trying literate programming and in my attempts to reference a source code block **A** from source code block **B** I get the following behavior which is not what i need.
Is my approach wrong or am I missing something?
org-version: 9.5.2; emacs-version: 28.1; distribution: spacemacs
#+name: A
#+begin_src js
() => {
console.log('hello world')
}
#+end_src
#+name: B
#+begin_src js :noweb yes
let fn = <<A>>
#+end_src
should the outcome of the expansion be?
let fn = () => {
console.log('hello world')
}
Instead I get:
let fn = () => {
let fn = console.log('hello world')
let fn = }
I found this [article in stack overflow](https://stackoverflow.com/questions/8454215/fixed-emacsorg-babel-noweb-reference-expand-with-an-surplus-line) which is very similar if not the same problem I am having; but does not help since it attributes the problem to an old org-mode version.
Cheers,
pnoul
organic-bookworm · 2022-08-26 10:56
> but does not help since it attributes the problem to an old org-mode version.
Well, I'm at Org mode 9.6 `00adad935` and it's got `:noweb-prefix no`, i.e.
#+name: B
#+begin_src js :noweb yes :noweb-prefix no
let fn = <<A>>
#+end_src
pnoulis · 2022-08-26 11:31
Thank you.
I am using spacemacs and ( cant / don't know how) to update org mode to the latest version; i will have to suffer workarounds.
organic-bookworm · 2022-08-26 12:36
RTFM or ask Spacemacs guys how to properly use a custom recipe for a package within a layer. There certainly is a way. Of course, by doing so you are risking breaking layer integrity.
pnoulis · 2022-08-26 14:58
/\\ -\_- /\\ something like that.
yantar92 · 2022-08-28 02:16
What you are seeing is described in https://orgmode.org/manual/Noweb-Reference-Syntax.html (search for "Noweb insertions honor prefix characters that appear before the noweb syntax reference.").
As, /u/organic-bookworm mentioned, the development Org version has a switch to disable this behaviour. If you are using the older version, you need to move the noweb reference to a new line. I am sure js has some equivalent of "\" to split lines of code.
pnoulis · 2022-09-01 19:13
This was most educational. Thank you.