emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* noweb
@ 2020-01-22 19:41 Nuno Salgado
  2020-01-22 20:21 ` noweb Marco Wahl
  2020-01-22 22:14 ` noweb Diego Zamboni
  0 siblings, 2 replies; 8+ messages in thread
From: Nuno Salgado @ 2020-01-22 19:41 UTC (permalink / raw)
  To: Emacs-orgmode

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: noweb
  2020-01-22 19:41 noweb Nuno Salgado
@ 2020-01-22 20:21 ` Marco Wahl
  2020-01-23  0:04   ` noweb Nuno Salgado
  2020-01-22 22:14 ` noweb Diego Zamboni
  1 sibling, 1 reply; 8+ messages in thread
From: Marco Wahl @ 2020-01-22 20:21 UTC (permalink / raw)
  To: Nuno Salgado; +Cc: Emacs-orgmode

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: noweb
  2020-01-22 19:41 noweb Nuno Salgado
  2020-01-22 20:21 ` noweb Marco Wahl
@ 2020-01-22 22:14 ` Diego Zamboni
  2020-01-23  0:18   ` noweb Nuno Salgado
  1 sibling, 1 reply; 8+ messages in thread
From: Diego Zamboni @ 2020-01-22 22:14 UTC (permalink / raw)
  To: Nuno Salgado; +Cc: Org-mode

[-- 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 --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: noweb
  2020-01-22 20:21 ` noweb Marco Wahl
@ 2020-01-23  0:04   ` Nuno Salgado
  2020-01-23  7:58     ` noweb Marco Wahl
  0 siblings, 1 reply; 8+ messages in thread
From: Nuno Salgado @ 2020-01-23  0:04 UTC (permalink / raw)
  To: Marco Wahl; +Cc: Emacs-orgmode

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: noweb
  2020-01-22 22:14 ` noweb Diego Zamboni
@ 2020-01-23  0:18   ` Nuno Salgado
  2020-01-23  7:00     ` noweb Fraga, Eric
  0 siblings, 1 reply; 8+ messages in thread
From: Nuno Salgado @ 2020-01-23  0:18 UTC (permalink / raw)
  To: Diego Zamboni; +Cc: Org-mode

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
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: noweb
  2020-01-23  0:18   ` noweb Nuno Salgado
@ 2020-01-23  7:00     ` Fraga, Eric
  2020-01-23 19:17       ` noweb Nick Dokos
  0 siblings, 1 reply; 8+ messages in thread
From: Fraga, Eric @ 2020-01-23  7:00 UTC (permalink / raw)
  To: Nuno Salgado; +Cc: Diego Zamboni, Org-mode

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: noweb
  2020-01-23  0:04   ` noweb Nuno Salgado
@ 2020-01-23  7:58     ` Marco Wahl
  0 siblings, 0 replies; 8+ messages in thread
From: Marco Wahl @ 2020-01-23  7:58 UTC (permalink / raw)
  To: Nuno Salgado; +Cc: Emacs-orgmode

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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: noweb
  2020-01-23  7:00     ` noweb Fraga, Eric
@ 2020-01-23 19:17       ` Nick Dokos
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Dokos @ 2020-01-23 19:17 UTC (permalink / raw)
  To: emacs-orgmode

"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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-01-23 19:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-22 19:41 noweb Nuno Salgado
2020-01-22 20:21 ` noweb Marco Wahl
2020-01-23  0:04   ` noweb Nuno Salgado
2020-01-23  7:58     ` noweb Marco Wahl
2020-01-22 22:14 ` noweb Diego Zamboni
2020-01-23  0:18   ` noweb Nuno Salgado
2020-01-23  7:00     ` noweb Fraga, Eric
2020-01-23 19:17       ` noweb Nick Dokos

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).