emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Lawrence Bottorff <borgauf@gmail.com>
To: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: babel srcname? Calling Library of Babel code?
Date: Tue, 6 Oct 2015 18:16:40 +0000	[thread overview]
Message-ID: <CAFAhFSV93Nf4SqpUME16cLTctNGoqiJK2PE=VBBMUFYCRqXcAQ@mail.gmail.com> (raw)
In-Reply-To: <m28u7g37dc.fsf@tsdye.com>

[-- Attachment #1: Type: text/plain, Size: 2878 bytes --]

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> wrote:

> Aloha Lawrence,
>
> Lawrence Bottorff <borgauf@gmail.com> 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
> > <http://orgmode.org/manual/Evaluating-code-blocks.html> 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 <arguments> part, non-:var arguments that change what
> the code block does in <inside header arguments>, and non-:var arguments
> that affect how the buffer is changed in the <end header arguments>.
>
> >
> > 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
> >>   Yours Truly
> >> #+end_src
> > . . .
> > and then
> >
> > . . .
> > \setupdocument{
> >>     to = {%
> >>           <<to>>},
> > . . .
> >>     opening = {<<opening>>},
> >>     closing = {<<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 <<foo>> form is noweb reference syntax.  Your example expands the
> source code block.  You can get the results of the source code block
> with <<opening()>>, 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
>

[-- Attachment #2: Type: text/html, Size: 4275 bytes --]

  reply	other threads:[~2015-10-06 18:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06  3:43 babel srcname? Calling Library of Babel code? Lawrence Bottorff
2015-10-06  5:15 ` Thomas S. Dye
2015-10-06 18:16   ` Lawrence Bottorff [this message]
2015-10-06 18:59     ` Nick Dokos
2015-10-06 19:00     ` Thomas S. Dye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFAhFSV93Nf4SqpUME16cLTctNGoqiJK2PE=VBBMUFYCRqXcAQ@mail.gmail.com' \
    --to=borgauf@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).