From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicholas Patrick Subject: Re: Org babel with multiple linked segments of source code Date: Fri, 25 Mar 2011 09:12:30 -0500 Message-ID: References: <87lj06a677.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0cd608366a47cb049f4f304e Return-path: Received: from [140.186.70.92] (port=35491 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q37ky-0004NQ-Qp for emacs-orgmode@gnu.org; Fri, 25 Mar 2011 10:12:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q37kx-0005g0-97 for emacs-orgmode@gnu.org; Fri, 25 Mar 2011 10:12:52 -0400 Received: from mail-qw0-f41.google.com ([209.85.216.41]:48789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q37kx-0005aK-4f for emacs-orgmode@gnu.org; Fri, 25 Mar 2011 10:12:51 -0400 Received: by mail-qw0-f41.google.com with SMTP id 26so804582qwa.0 for ; Fri, 25 Mar 2011 07:12:50 -0700 (PDT) In-Reply-To: <87lj06a677.fsf@gmail.com> 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 --000e0cd608366a47cb049f4f304e Content-Type: text/plain; charset=ISO-8859-1 I may try playing around with the sequential sections...since that's how I'm currently writing the majority of this file. Most of the pieces of code are simply defining functions that call other functions or macros and wouldn't be executed alone. However, I'm defining other blocks as tests for the functional sections. So I might do the following: #+source: functional-definitions #+begin_src emacs-lisp (defn f1 #+end_src #+source: functional-definitions #+begin_src emacs-lisp (defn f2 #+end_src #+begin_src emacs-lisp <> (def xyz (f1 (f2 foo))) ; produces bar #+end_src #+results: | bar | I'm still pretty new to using babel, so I haven't figured out much other than the basic tangling capability. Maybe my example could be accomplished with something like a ':concatenate yes' option on the functional-definitions blocks. On Tue, Mar 22, 2011 at 9:57 PM, Eric Schulte wrote: > Hi, > > The setup you suggest below is not currently supported. I fear > implementing such a system could have some odd semantic extensions into > other parts of Org-mode code blocks, for example, would it then make > sense for the results of a code block to be collected over all code > blocks with that name? For example, > > #+source: test2 > #+begin_src emacs-lisp > 1 > #+end_src > > #+source: test2 > #+begin_src emacs-lisp > 2 > #+end_src > > #+begin_src emacs-lisp :var data=test2 > data > #+end_src > > #+results: > | 1 | 2 | > > Maybe, but this is certainly not possible under the current setup. > > Anyways, back to your use case, maybe it would be equally convenient to > simply have a number of sequential code blocks in the Org-mode file all > tangle out, as they will be placed in the tangled file in the order they > appear in the Org-mode file, so your example below could be changed > to... > > ** tangling example > :PROPERTIES: > :tangle: test1.clj > :exports: none > :END: > > #+begin_src clojure > blah > #+end_src > > #+begin_src clojure > foo > #+end_src > > #+begin_src clojure > bar > #+end_src > > #+begin_src clojure > blah > #+end_src > > While not the same as what you suggested this may be sufficient. > > Best -- Eric > > Nicholas Patrick writes: > > > I'm trying to figure out how to minimize the overhead with using babel to > > write some segments of code. I find myself writing short segments of a > set > > of functionality, then writing a collector source block which is referred > to > > later on in the code... e.g. > > > > ********************* > > #+srcname: test1 > > #+begin_src clojure :tangle test1.clj :exports none :noweb yes > > blah > > <> > > blah > > #+end_src > > > > #+srcname: test2 > > #+begin_src clojure > > foo > > #+end_src > > > > #+srcname: test2 > > #+begin_src clojure > > bar > > #+end_src > > ********************* > > I'd like to see > > blah > > foo > > bar > > blah > > > > but I see > > blah > > foo > > blah > > > > What I'd like to see is a single srcname for the code that just > concatenates > > the two different sections when it is referred by <>. > > That way I don't have to come up with different names and collectors and > so > > on and so forth. Maybe I'm just not doing "literate programming" right, > but > > when I'm hacking stuff together, I'd like to minimize the housekeeping. > > e.g. > > > > Is there a way to do this? > > --000e0cd608366a47cb049f4f304e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I may try playing around with the sequential sections...since that's ho= w I'm currently writing the majority of this file.=A0 Most of the piece= s of code are simply defining functions that call other functions or macros= and wouldn't be executed alone.=A0 However, I'm defining other blo= cks as tests for the functional sections.=A0 So I might do the following:
#+source: functional-definitions
#+begin_src emacs-lisp
(defn f1
#+end_src

#+source: functional-definitions
#+begin_src emacs-lisp
(defn f2
#+end_src

#+begin_src emacs-lisp
<<functional-definitions>>
(def xy= z (f1 (f2 foo))) ; produces bar
#+end_src

#+results:
| bar |

I'm still pretty new to using babel, so I haven't figured out m= uch other than the basic tangling capability.=A0 Maybe my example could be = accomplished with something like a ':concatenate yes' option on the= functional-definitions blocks.=A0

On Tue, Mar 22, 2011 at 9:57 PM, Eric Schult= e <schulte.e= ric@gmail.com> wrote:
Hi,

The setup you suggest below is not currently supported. =A0I fear
implementing such a system could have some odd semantic extensions into
other parts of Org-mode code blocks, for example, would it then make
sense for the results of a code block to be collected over all code
blocks with that name? =A0For example,

#+source: test2
#+begin_src emacs-lisp
=A01
#+end_src

#+source: test2
#+begin_src emacs-lisp
=A02
#+end_src

#+begin_src emacs-lisp :var data=3Dtest2
=A0data
#+end_src

#+results:
| 1 | 2 |

Maybe, but this is certainly not possible under the current setup.

Anyways, back to your use case, maybe it would be equally convenient to
simply have a number of sequential code blocks in the Org-mode file all
tangle out, as they will be placed in the tangled file in the order they appear in the Org-mode file, so your example below could be changed
to...

** tangling example
=A0 :PROPERTIES:
=A0 :tangle: =A0 test1.clj
=A0 :exports: =A0none
=A0 :END:

#+begin_src clojure
=A0blah
#+end_src

#+begin_src clojure
=A0foo
#+end_src

#+begin_src clojure
=A0bar
#+end_src

#+begin_src clojure
=A0blah
#+end_src

While not the same as what you suggested this may be sufficient.

Best -- Eric

Nicholas Patrick <npatrick04@gma= il.com> writes:

> I'm trying to figure out how to minimize the overhead with using b= abel to
> write some segments of code. =A0I find myself writing short segments o= f a set
> of functionality, then writing a collector source block which is refer= red to
> later on in the code... e.g.
>
> *********************
> #+srcname: test1
> #+begin_src clojure :tangle test1.clj :exports none :noweb yes
> blah
> <<test2>>
> blah
> #+end_src
>
> #+srcname: test2
> #+begin_src clojure
> foo
> #+end_src
>
> #+srcname: test2
> #+begin_src clojure
> bar
> #+end_src
> *********************
> I'd like to see
> blah
> foo
> bar
> blah
>
> but I see
> blah
> foo
> blah
>
> What I'd like to see is a single srcname for the code that just co= ncatenates
> the two different sections when it is referred by <<descriptive-= name>>.
> That way I don't have to come up with different names and collecto= rs and so
> on and so forth. =A0Maybe I'm just not doing "literate progra= mming" right, but
> when I'm hacking stuff together, I'd like to minimize the hous= ekeeping.
> e.g.
>
> Is there a way to do this?


--000e0cd608366a47cb049f4f304e--