From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: [babel] noweb for :sessions? Date: Mon, 19 Oct 2009 08:40:34 -1000 Message-ID: <1CC6DD15-EF97-4330-AA3F-BE7F22386A6B@tsdye.com> References: Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary="===============1272749238==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mzx9x-0004Hk-5C for emacs-orgmode@gnu.org; Mon, 19 Oct 2009 14:40:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mzx9s-00046N-9R for emacs-orgmode@gnu.org; Mon, 19 Oct 2009 14:40:44 -0400 Received: from [199.232.76.173] (port=55902 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mzx9s-00046E-5H for emacs-orgmode@gnu.org; Mon, 19 Oct 2009 14:40:40 -0400 Received: from outbound-mail-310.bluehost.com ([67.222.54.3]:36141) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Mzx9r-0005nY-GJ for emacs-orgmode@gnu.org; Mon, 19 Oct 2009 14:40:39 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org --===============1272749238== Content-Type: multipart/alternative; boundary=Apple-Mail-79-645044496 --Apple-Mail-79-645044496 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit 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 > # <> > 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" 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 >> # <> >> 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 --Apple-Mail-79-645044496 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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

=

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 =3D = 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=3D"user_name", = password=3D"password",
=             &n= bsp;       dbname=3D"db_name", = host=3D"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

= --Apple-Mail-79-645044496-- --===============1272749238== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============1272749238==--