Re: [FR] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments)
Sébastien Miquel writes: > The uses are maybe too niche to warrant the breaking change. A syntax > extension like > : var=block-id[] > seems possible, even though brackets are already overloaded. This sounds better. Using brackets will actually make a lot of sense. Currently, we have roughly the following logic in the :var references: - :var x=reference() will execute the reference and assign the returned value - :var x=reference[] will take the reference text representation, possibly process it according to the parameters, and return the processed text *this only works for tables* - :var x=reference will perform some "default" action depending on the reference type. the action may be "execute" or "get text representation" for source blocks and others correspondingly. Extending reference[...] syntax to all the element types will make things consistent and allow future extensions if we decide to provide "index" syntax for non-tables (code lines, function definitions?) > One alternative is to only allow the syntax inside noweb brackets > instead of generic variable arguments. I assume there'd be much less > breakage. It would also makes sense to allow noweb references instead > of block ids. We'd add support for > : <> > and <> would also insert the contents as a > by-product. This would still be a breaking change. And we will introduce inconsistency between resolving noweb references and resolving :var header args. Moreover, resolving references is currently handled by the same code inside :vars and noweb references. Changing this will complicate the source code as well, IMHO increasing the maintenance burden too much. > Do you have any example of use in mind, beyond my original one ? For example, one may convert .el file commentary to Readme.org: #+name: my-library #+begin_src :tangle my-library.el ;; Commentary: ;; A lot of commentary #+end_src #+begin_src :exports results :var commentary=my-library[] (convert-to-org-headlines commentary) #+end_src Best, Ihor
Re: [FR] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments)
Hi, Ihor Radchenko writes: > Hmm. You are right. I missed "optionally". > > Still, I find this idea as the best solution for people who want to > process the source block text during noweb expansion. > > Alternative ideas are welcome though. I'd prefer to avoid breaking > change if we can find an equally simple syntax alternative to assign > source block code to a variable. The uses are maybe too niche to warrant the breaking change. A syntax extension like : var=block-id[] seems possible, even though brackets are already overloaded. One alternative is to only allow the syntax inside noweb brackets instead of generic variable arguments. I assume there'd be much less breakage. It would also makes sense to allow noweb references instead of block ids. We'd add support for : <> and <> would also insert the contents as a by-product. Do you have any example of use in mind, beyond my original one ? Regards, -- Sébastien Miquel
Re: [FR] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments)
Ihor, > Alternative ideas are welcome though. I'd prefer to avoid breaking > change if we can find an equally simple syntax alternative to assign > source block code to a variable. my two cents would be to avoid the breaking change. (i notice, for example, that i use this construct in some of my .org files.) cheers, Greg
Re: [FR] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments)
Greg Minshall writes: >> The current behaviour of :var foo=name-of-src-block is assigning result >> of evaluation. However, this behaviour is actually not documented. >> 16.4 Environment of a Code Block section of the manual only documents >> uses like > > in fact, the text of the info page (on my system?) says >> code block without arguments >> A code block name, as assigned by ‘NAME’ keyword from the example >> above, optionally followed by parentheses. > > note the "optionally". Hmm. You are right. I missed "optionally". Still, I find this idea as the best solution for people who want to process the source block text during noweb expansion. Alternative ideas are welcome though. I'd prefer to avoid breaking change if we can find an equally simple syntax alternative to assign source block code to a variable. Best, Ihor
Re: [FR] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments)
Ihor, > The current behaviour of :var foo=name-of-src-block is assigning result > of evaluation. However, this behaviour is actually not documented. > 16.4 Environment of a Code Block section of the manual only documents > uses like in fact, the text of the info page (on my system?) says > code block without arguments > A code block name, as assigned by ‘NAME’ keyword from the example > above, optionally followed by parentheses. note the "optionally". cheers, Greg