emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Insert variable into tangled source code
@ 2013-08-06 13:43 Roland
  2013-08-06 13:57 ` Sebastien Vauban
  0 siblings, 1 reply; 3+ messages in thread
From: Roland @ 2013-08-06 13:43 UTC (permalink / raw)
  To: emacs-orgmode

Hello!

I use orgmode to write code in a IA language developped by the company I 
work for. Everything was just nice when I attempted to insert in the source 
code a value set up in my org buffer.

Here is the real situation :


#+TBLNAME: tab_x
| x | 1 |

#+begin_src own_lang :tangle ./tangle_file :var x=x[0,1]
TYPE OBJ;

    CONSTANTE 
        var_x DOMAIN INTEGER DEFAULT $x
#+end_src

and I would except in tangle_file :
TYPE OBJ;

    CONSTANTE 
        var_x DOMAIN INTEGER DEFAULT 1

But unfortunately, I get 
TYPE OBJ;

    CONSTANTE 
        var_x DOMAIN INTEGER DEFAULT $x

Any ideas???

Thanks in advance.

Roland.

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

* Re: Insert variable into tangled source code
  2013-08-06 13:43 Insert variable into tangled source code Roland
@ 2013-08-06 13:57 ` Sebastien Vauban
  2013-08-06 14:40   ` Roland
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastien Vauban @ 2013-08-06 13:57 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Roland wrote:
> I use orgmode to write code in a IA language developped by the company I 
> work for. Everything was just nice when I attempted to insert in the source 
> code a value set up in my org buffer.
>
> Here is the real situation :
>
> #+TBLNAME: tab_x
> | x | 1 |
> #+begin_src own_lang :tangle ./tangle_file :var x=x[0,1]
> TYPE OBJ;
>
>     CONSTANTE 
>         var_x DOMAIN INTEGER DEFAULT $x
> #+end_src
>
> and I would except in tangle_file :
> TYPE OBJ;
>
>     CONSTANTE 
>         var_x DOMAIN INTEGER DEFAULT 1
>
> But unfortunately, I get 
> TYPE OBJ;
>
>     CONSTANTE 
>         var_x DOMAIN INTEGER DEFAULT $x
>
> Any ideas???

First, x[0,1] can't be resolved (unlike tab_x[0,1]).

For the rest, I'd guess you must add the proper replacemen "method" for
`own_lang'. Is this the case?

I mean: depending on the Babel language, variables must or must not be
prefixed by a $ sign to be replaced in the code block. For example, in Emacs
Lisp, you won't prefix vars with $.

Maybe have a look at `sh' or `sql' Babel languages for inspiration.

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Insert variable into tangled source code
  2013-08-06 13:57 ` Sebastien Vauban
@ 2013-08-06 14:40   ` Roland
  0 siblings, 0 replies; 3+ messages in thread
From: Roland @ 2013-08-06 14:40 UTC (permalink / raw)
  To: emacs-orgmode

Sebastien Vauban <sva-news@...> writes:

> 
> First, x[0,1] can't be resolved (unlike tab_x[0,1]).
> 
> For the rest, I'd guess you must add the proper replacemen "method" for
> `own_lang'. Is this the case?
> 
> I mean: depending on the Babel language, variables must or must not be
> prefixed by a $ sign to be replaced in the code block. For example, in 
Emacs
> Lisp, you won't prefix vars with $.
> 
> Maybe have a look at `sh' or `sql' Babel languages for inspiration.
> 
> Best regards,
>   Seb
> 

Thank you very much!!!

I've just adapted the SQL expand variable function in ob-sql.el to my 
language and it works perfectly!

Best regards.

Roland.

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

end of thread, other threads:[~2013-08-06 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-06 13:43 Insert variable into tangled source code Roland
2013-08-06 13:57 ` Sebastien Vauban
2013-08-06 14:40   ` Roland

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