emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] noweb for :sessions?
@ 2009-10-19 17:12 Thomas S. Dye
  2009-10-19 18:15 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas S. Dye @ 2009-10-19 17:12 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 661 bytes --]

Aloha all,

Is it possible to define frequently used code snippets in a generic  
way so they can be used in different sessions?

Something like this is what I have in mind:

#+srcname: r-connect
#+begin_src R :exports none :session any
library(rMySQL)
con <- dbConnect(MySQL(), user="user_name", password="password",
                      dbname="db_name", host="host_name")
#+end_src

#+srcname: r-query
#+begin_src R :session session-1
# <<r-connect>>
res <- dbGetQuery(con, "select * from table_name where 1")
#+end_src

Tom

Thomas S. Dye, Ph.D.
T. S. Dye & Colleagues, Archaeologists, Inc.
Phone: (808) 529-0866 Fax: (808) 529-0884
http://www.tsdye.com



[-- Attachment #1.2: Type: text/html, Size: 3310 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [babel] noweb for :sessions?
  2009-10-19 17:12 [babel] noweb for :sessions? Thomas S. Dye
@ 2009-10-19 18:15 ` Eric Schulte
  2009-10-19 18:40   ` Thomas S. Dye
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2009-10-19 18:15 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode

Hi Tom,

That is an interesting proposal, and surprisingly simple to implement.
Please pull the latest version of Org-mode, and you will find that there
is now a :noweb header argument available for source-code blocks which
has the effect of expanding noweb references before source-block
evaluation (as you suggested below).  So for example the following
works.

--8<---------------cut here---------------start------------->8---
#+srcname: noweb-example
#+begin_src ruby 
  a = 28
#+end_src

#+begin_src ruby :noweb
  # <<noweb-example>>
  a + 4
#+end_src

#+resname:
: 32
--8<---------------cut here---------------end--------------->8---

Does this satisfy the behavior you were suggesting?

Thanks for the idea! -- Eric

"Thomas S. Dye" <tsd@tsdye.com> writes:

> Aloha all,
>
> Is it possible to define frequently used code snippets in a generic way so they can be used in different
> sessions?
>
> Something like this is what I have in mind:
>
> #+srcname: r-connect
> #+begin_src R :exports none :session any
> library(rMySQL)
> con <- dbConnect(MySQL(), user="user_name", password="password", 
>                      dbname="db_name", host="host_name")
> #+end_src
>
> #+srcname: r-query
> #+begin_src R :session session-1 
> # <<r-connect>>
> res <- dbGetQuery(con, "select * from table_name where 1")
> #+end_src
>
> Tom
>
> Thomas S. Dye, Ph.D.
>
> T. S. Dye & Colleagues, Archaeologists, Inc.
>
> Phone: (808) 529-0866 Fax: (808) 529-0884
>
> http://www.tsdye.com
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [babel] noweb for :sessions?
  2009-10-19 18:15 ` Eric Schulte
@ 2009-10-19 18:40   ` Thomas S. Dye
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas S. Dye @ 2009-10-19 18:40 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2080 bytes --]

Hi Eric,

Yes, I think that's it.  I appreciate your help.  org-babel has me  
feeling like a kid at Christmas.

Tom

Thomas S. Dye, Ph.D.
T. S. Dye & Colleagues, Archaeologists, Inc.
Phone: (808) 529-0866 Fax: (808) 529-0884
http://www.tsdye.com


On Oct 19, 2009, at 8:15 AM, Eric Schulte wrote:

> Hi Tom,
>
> That is an interesting proposal, and surprisingly simple to implement.
> Please pull the latest version of Org-mode, and you will find that  
> there
> is now a :noweb header argument available for source-code blocks which
> has the effect of expanding noweb references before source-block
> evaluation (as you suggested below).  So for example the following
> works.
>
> --8<---------------cut here---------------start------------->8---
> #+srcname: noweb-example
> #+begin_src ruby
>  a = 28
> #+end_src
>
> #+begin_src ruby :noweb
>  # <<noweb-example>>
>  a + 4
> #+end_src
>
> #+resname:
> : 32
> --8<---------------cut here---------------end--------------->8---
>
> Does this satisfy the behavior you were suggesting?
>
> Thanks for the idea! -- Eric
>
> "Thomas S. Dye" <tsd@tsdye.com> writes:
>
>> Aloha all,
>>
>> Is it possible to define frequently used code snippets in a generic  
>> way so they can be used in different
>> sessions?
>>
>> Something like this is what I have in mind:
>>
>> #+srcname: r-connect
>> #+begin_src R :exports none :session any
>> library(rMySQL)
>> con <- dbConnect(MySQL(), user="user_name", password="password",
>>                     dbname="db_name", host="host_name")
>> #+end_src
>>
>> #+srcname: r-query
>> #+begin_src R :session session-1
>> # <<r-connect>>
>> res <- dbGetQuery(con, "select * from table_name where 1")
>> #+end_src
>>
>> Tom
>>
>> Thomas S. Dye, Ph.D.
>>
>> T. S. Dye & Colleagues, Archaeologists, Inc.
>>
>> Phone: (808) 529-0866 Fax: (808) 529-0884
>>
>> http://www.tsdye.com
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Remember: use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[-- Attachment #1.2: Type: text/html, Size: 6283 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2009-10-19 18:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-19 17:12 [babel] noweb for :sessions? Thomas S. Dye
2009-10-19 18:15 ` Eric Schulte
2009-10-19 18:40   ` Thomas S. Dye

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