From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: [babel] noweb for :sessions? Date: Mon, 19 Oct 2009 12:15:24 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mzwla-0002Kb-FX for emacs-orgmode@gnu.org; Mon, 19 Oct 2009 14:15:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MzwlV-0002G0-PA for emacs-orgmode@gnu.org; Mon, 19 Oct 2009 14:15:34 -0400 Received: from [199.232.76.173] (port=59857 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzwlV-0002Fn-J5 for emacs-orgmode@gnu.org; Mon, 19 Oct 2009 14:15:29 -0400 Received: from mail-px0-f202.google.com ([209.85.216.202]:61930) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MzwlV-0000mv-9N for emacs-orgmode@gnu.org; Mon, 19 Oct 2009 14:15:29 -0400 Received: by pxi40 with SMTP id 40so3998934pxi.24 for ; Mon, 19 Oct 2009 11:15:28 -0700 (PDT) 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: "Thomas S. Dye" Cc: emacs-orgmode@gnu.org 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