From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: Re: babel srcname? Calling Library of Babel code? Date: Tue, 6 Oct 2015 18:16:40 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c3c47caecce8052173a1b4 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjWn5-0005VU-V4 for emacs-orgmode@gnu.org; Tue, 06 Oct 2015 14:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjWn4-0002Tt-Ar for emacs-orgmode@gnu.org; Tue, 06 Oct 2015 14:16:43 -0400 Received: from mail-la0-x22b.google.com ([2a00:1450:4010:c03::22b]:35140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjWn3-0002Tn-Ut for emacs-orgmode@gnu.org; Tue, 06 Oct 2015 14:16:42 -0400 Received: by lacdq7 with SMTP id dq7so6817884lac.2 for ; Tue, 06 Oct 2015 11:16:41 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode Mailinglist --001a11c3c47caecce8052173a1b4 Content-Type: text/plain; charset=UTF-8 Thanks for the info, T. Now, if I commit a file of source code blocks to be "library of babel," how do I then call them? Is there some sort of prefix? On Tue, Oct 6, 2015 at 5:15 AM, Thomas S. Dye wrote: > Aloha Lawrence, > > Lawrence Bottorff writes: > > > Not really getting how to call code "meta-style" from other points -- in > my > > file, in other files, in my "library of babel" file? I've tracked down > bits > > and pieces here and there, but I'm missing the big picture. > > > > For example, this: > > > > #+srcname: python2_env > > #+begin_src emacs-lisp > > (setq org-babel-python-command "python") > > (set-face-background 'modeline "#4477aa") > > #+end_src > > > > #+srcname: python3_env > > #+begin_src emacs-lisp > > (setq org-babel-python-command "python3") > > (set-face-background 'modeline "#771944") > > #+end_src > > > > Why is #+srcname being used and not just #+name? I assume these blocks > will > > be called later? I'm also assuming that #+call plays a role, but this > page > > has no examples > and > > confused me. > > During development of Babel, source code blocks were originally named > using #+srcname:. Later, as other elements gained the ability to be > named, it was decided to use a more generic identifier, #+name:. > > The #+call: syntax is confusing to me, too. I usually put :var > arguments in the part, non-:var arguments that change what > the code block does in , and non-:var arguments > that affect how the buffer is changed in the . > > > > > This example > > > again > > uses #+srcname: > > > > . . . > > * Opening > >> #+srcname: opening > >> #+begin_src org > >> Dear Org mode users, > >> #+end_src > > . . . > > * Closing > >> #+srcname: closing > >> #+begin_src org > >> Yours Truly > >> #+end_src > > . . . > > and then > > > > . . . > > \setupdocument{ > >> to = {% > >> <>}, > > . . . > >> opening = {<>}, > >> closing = {<>} > >> } > > > > I'm guessing the opening and closing are being called. But again, why > > srcname and not just name? And what if my blocks had been defined > somewhere > > outside of this file? > > The <> form is noweb reference syntax. Your example expands the > source code block. You can get the results of the source code block > with <>, which I think is what this example might intend. > > If the blocks are defined outside of the file, then where they are > defined is a library of Babel. You'll need to explicitly load them with > the org-babel-lob-ingest function. You can have as many libraries of > Babel as you want. > > hth, > Tom > > -- > Thomas S. Dye > http://www.tsdye.com > --001a11c3c47caecce8052173a1b4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the info, T. Now, if I commit a file of source = code blocks to be "library of babel," how do I then call them? Is= there some sort of prefix?

On Tue, Oct 6, 2015 at 5:15 AM, Thomas S. Dye <tsd@tsdye.com<= /a>> wrote:
Aloha Lawrence,

Lawrence Bottorff <
borgauf@gmail.co= m> writes:

> Not really getting how to call code "meta-style" from other = points -- in my
> file, in other files, in my "library of babel" file? I'v= e tracked down bits
> and pieces here and there, but I'm missing the big picture.
>
> For example, this:
>
> #+srcname: python2_env
> #+begin_src emacs-lisp
>=C2=A0 =C2=A0(setq org-babel-python-command "python")
>=C2=A0 =C2=A0(set-face-background 'modeline "#4477aa") > #+end_src
>
> #+srcname: python3_env
> #+begin_src emacs-lisp
>=C2=A0 =C2=A0(setq org-babel-python-command "python3")
>=C2=A0 =C2=A0(set-face-background 'modeline "#771944") > #+end_src
>
> Why is #+srcname being used and not just #+name? I assume these blocks= will
> be called later? I'm also assuming that #+call plays a role, but t= his page
> <http://orgmode.org/manual/Evalu= ating-code-blocks.html> has no examples and
> confused me.

During development of Babel, source code blocks were originally named
using #+srcname:.=C2=A0 Later, as other elements gained the ability to be named, it was decided to use a more generic identifier, #+name:.

The #+call: syntax is confusing to me, too.=C2=A0 I usually put :var
arguments in the <arguments> part, non-:var arguments that change wha= t
the code block does in <inside header arguments>, and non-:var argume= nts
that affect how the buffer is changed in the <end header arguments>.<= br>
>
> This example
> <https://lists.gnu.org= /archive/html/emacs-orgmode/2010-09/msg00466.html> again
> uses #+srcname:
>
> . . .
> * Opening
>> #+srcname: opening
>> #+begin_src org
>> Dear Org mode users,
>> #+end_src
> . . .
> * Closing
>> #+srcname: closing
>> #+begin_src org
>>=C2=A0 =C2=A0Yours Truly
>> #+end_src
> . . .
> and then
>
> . . .
> \setupdocument{
>>=C2=A0 =C2=A0 =C2=A0to =3D {%
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<<to>>},
> . . .
>>=C2=A0 =C2=A0 =C2=A0opening =3D {<<opening>>},
>>=C2=A0 =C2=A0 =C2=A0closing =3D {<<closing>>}
>> }
>
> I'm guessing the opening and closing are being called. But again, = why
> srcname and not just name? And what if my blocks had been defined some= where
> outside of this file?

The <<foo>> form is noweb reference syntax.=C2=A0 Y= our example expands the
source code block.=C2=A0 You can get the results of the source code block with <<opening()>>, which I think is what this example might in= tend.

If the blocks are defined outside of the file, then where they are
defined is a library of Babel.=C2=A0 You'll need to explicitly load the= m with
the org-babel-lob-ingest function.=C2=A0 You can have as many libraries of<= br> Babel as you want.

hth,
Tom

--
Thomas S. Dye
http:= //www.tsdye.com

--001a11c3c47caecce8052173a1b4--