Hot answers tagged

4

There may be other solutions, this is how I would do it: #+begin_src sh :noweb yes :var res=test-fn() echo $res #+end_src #+results: : testvar=This is a test The same can be done without introducing the dummy variable (as is described in the documentation): #+begin_src sh :noweb yes echo <<test-fn()>> #+end_src #+results: : testvar=This is a ...


3

I think there is already a parser for src block names in org-babel-src-block-names returning a list. The following provides programmed completion for that list: (defun org-src-block-names--completion-function (str pred action) (let ((tbl (org-babel-src-block-names))) (pcase action (`nil (try-completion str tbl pred)) (`t (all-...


2

To export a buffer without expanding noweb references, you can set the following at your src header, as per documentation: #+begin_src language :noweb no-export To define that globally, you can add the following at the top of your Org File: #+property: header-args :noweb no-export Or language specific: #+property: header-args:languagename :noweb no-...


2

Try this The reason why the error happens is because you haven't defined y in the x=y arguments. If you update code as follows noweb will work #+NAME: cubed-plus-cubed #+BEGIN_SRC python :noweb eval return <<cubed(x=3)>> + <<cubed(x=3)>> #+END_SRC #+RESULTS: cubed-plus-cubed : 54 However I suspect this is not what you wanted ...


2

I understand your confusion. The good news is that your code is already passing new lines correctly into your noweb call. The reason you're seeing the eval: Symbol’s value as variable is void: a error is because of the generated elisp code. If you execute the following code you'll see the same error message: #+BEGIN_src elisp a b c #+END_src A ...


2

I think you're asking how to prefix only the first line of the noweb block. It will probably depend on the language your using, but I came up with this hack for bash: #+NAME: example #+BEGIN_SRC text please echo this line date ## but not this one cd test ## this one ls -l ## or this one #+END_SRC Bad source code block, echo prepended to very line: #+...


2

This is only a partial solution, but the dabbrev-expand method can be greatly improved by modifying the syntax table so that < and > are treated as delimiters: (modify-syntax-entry ?< "(>" org-mode-syntax-table) (modify-syntax-entry ?> ")<" org-mode-syntax-table) This means that you don't have to go back and insert a space before using M-/...


2

The behavior you want is controlled by the variable org-babel-noweb-error-all-langs, whose default value is nil. Set it to t (e.g. via (setq org-babel-noweb-error-all-langs t) in your init file), and unresolvable noweb references will raise an error.


1

Your example works if I set all headers with :noweb yes and then only the last block has :tangle yes. A simpler example: Add this at the top of the file: #+PROPERTY: header-args :noweb yes :tangle no :exports code Remove all header args from the code blocks. Add :tangle yes header to the "full specification".


Only top voted, non community-wiki answers of a minimum length are eligible