Hi, I'm writing an installation script in org-mode. I'm doing something like this: Vars definition: #+NAME:DEFVARS #+BEGIN_SRC shell :tangle yes v1=1; v2=2; #+END_SRC Script1: #+BEGIN_SRC shell :tangle yes :noweb eval <<DEFVARS>> echo $v1; #+END_SRC Script2: #+BEGIN_SRC shell :tangle yes :noweb eval <<DEFVARS>> echo $v2; echo $v1; #+END_SRC This works great when I do C-c C-c in each script. But when I do org-babel-tangle, the code gets two <<DEFVARS>>. Does it makes sense? Since I set noweb = eval why does it exports <<DEFVARS>>? Could you please help me turning around this problem without removing every reference <<DEFVARS>> Thank you very much. Regards, NS
Nuno Salgado <nuno@salgado.eu> writes:
> Vars definition:
> #+NAME:DEFVARS
>
> #+BEGIN_SRC shell :tangle yes
> v1=1;
> v2=2;
> #+END_SRC
>
> Script1:
>
> #+BEGIN_SRC shell :tangle yes :noweb eval
> <<DEFVARS>>
> echo $v1;
> #+END_SRC
>
> This works great when I do C-c C-c in each script.
>
> But when I do org-babel-tangle, the code gets two <<DEFVARS>>.
>
> Does it makes sense? Since I set noweb = eval why does it exports
> <<DEFVARS>>?
>
> Could you please help me turning around this problem without removing every reference <<DEFVARS>>
You can find the answer in the documentation, I think. See e.g. (info
"(org) Noweb Reference Syntax").
HTH
--
Marco
[-- Attachment #1: Type: text/plain, Size: 1428 bytes --] Hi Nuno, ":noweb eval" means that noweb references are only expanded during evaluation of the code, but not during export. This is why you get the literal <<DEFVARS>> references in exported output. Here are the possible values of :noweb and what they mean: https://orgmode.org/manual/noweb.html Also note that if all of this is in the same file, both Script1 and Script2 will be tangled to the same file, you may want to specify different filenames as the value of :tangle (see https://orgmode.org/manual/tangle.html#tangle). Hope this helps, --Diego On Wed, Jan 22, 2020 at 8:41 PM Nuno Salgado <nuno@salgado.eu> wrote: > Hi, > > I'm writing an installation script in org-mode. > > I'm doing something like this: > > Vars definition: > #+NAME:DEFVARS > #+BEGIN_SRC shell :tangle yes > v1=1; > v2=2; > #+END_SRC > > Script1: > #+BEGIN_SRC shell :tangle yes :noweb eval > <<DEFVARS>> > echo $v1; > #+END_SRC > > Script2: > #+BEGIN_SRC shell :tangle yes :noweb eval > <<DEFVARS>> > echo $v2; > echo $v1; > #+END_SRC > > This works great when I do C-c C-c in each script. > > But when I do org-babel-tangle, the code gets two <<DEFVARS>>. > > Does it makes sense? Since I set noweb = eval why does it exports > <<DEFVARS>>? > > Could you please help me turning around this problem without removing > every reference <<DEFVARS>> > > Thank you very much. > > > Regards, > NS > > [-- Attachment #2: Type: text/html, Size: 2202 bytes --]
Marco,
Thank you for your help. I read it again and didn't find. But no
problem.
My question was to figure out what's the point to tangle the code without substituition!
NS
Marco Wahl <marcowahlsoft@gmail.com> writes:
> Nuno Salgado <nuno@salgado.eu> writes:
>
>> Vars definition:
>> #+NAME:DEFVARS
>>
>> #+BEGIN_SRC shell :tangle yes
>> v1=1;
>> v2=2;
>> #+END_SRC
>>
>> Script1:
>>
>> #+BEGIN_SRC shell :tangle yes :noweb eval
>> <<DEFVARS>>
>> echo $v1;
>> #+END_SRC
>>
>> This works great when I do C-c C-c in each script.
>>
>> But when I do org-babel-tangle, the code gets two <<DEFVARS>>.
>>
>> Does it makes sense? Since I set noweb = eval why does it exports
>> <<DEFVARS>>?
>>
>> Could you please help me turning around this problem without removing every reference <<DEFVARS>>
>
> You can find the answer in the documentation, I think. See e.g. (info
> "(org) Noweb Reference Syntax").
>
>
> HTH
Diego,
Thank you for your help.
Yes, I want the scripts to be all in one file in order to execute them
all. But it's nice do execute then individualy (C-c C-c) to test and debug.
I think I have to have 2 blocks of code for each script: one for tangle,
with no <<DEFVARS>> and another to test, with <<DEFVARS>> and <<SCRIPTn>>;
N
Diego Zamboni <diego@zzamboni.org> writes:
> Hi Nuno,
>
> ":noweb eval" means that noweb references are only expanded during
> evaluation of the code, but not during export. This is why you get
> the literal <<DEFVARS>> references in exported output. Here are the
> possible values of :noweb and what they mean: https://orgmode.org/
> manual/noweb.html
>
> Also note that if all of this is in the same file, both Script1 and
> Script2 will be tangled to the same file, you may want to specify
> different filenames as the value of :tangle (see https://orgmode.org/
> manual/tangle.html#tangle).
>
> Hope this helps,
> --Diego
>
>
> On Wed, Jan 22, 2020 at 8:41 PM Nuno Salgado <nuno@salgado.eu> wrote:
>
> Hi,
>
> I'm writing an installation script in org-mode.
>
> I'm doing something like this:
>
> Vars definition:
> #+NAME:DEFVARS
> #+BEGIN_SRC shell :tangle yes
> v1=1;
> v2=2;
> #+END_SRC
>
> Script1:
> #+BEGIN_SRC shell :tangle yes :noweb eval
> <<DEFVARS>>
> echo $v1;
> #+END_SRC
>
> Script2:
> #+BEGIN_SRC shell :tangle yes :noweb eval
> <<DEFVARS>>
> echo $v2;
> echo $v1;
> #+END_SRC
>
> This works great when I do C-c C-c in each script.
>
> But when I do org-babel-tangle, the code gets two <<DEFVARS>>.
>
> Does it makes sense? Since I set noweb = eval why does it exports
> <<DEFVARS>>?
>
> Could you please help me turning around this problem without
> removing every reference <<DEFVARS>>
>
> Thank you very much.
>
>
> Regards,
> NS
>
My approach to this is to create three blocks that are tangled and a separate block (or more than one if you have different tests you want to perform) for evaluation that references those three blocks (via noweb) but is not tangled. -- Eric S Fraga via Emacs 28.0.50, Org release_9.3.1-94-g0ac6a9
Nuno Salgado <nuno@salgado.eu> writes:
> My question was to figure out what's the point to tangle the code
> without substituition!
Your imagination is the limit. E.g. this could be useful to document
the ":noweb eval" behavior opposed to ":noweb yes".
"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
> My approach to this is to create three blocks that are tangled and a
> separate block (or more than one if you have different tests you want to
> perform) for evaluation that references those three blocks (via noweb)
> but is not tangled.
That works, but shouldn't Nuno's approach with :noweb eval work? What use
is it to include unexpanded noweb markers in the tangled output?
--
Nick
"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler