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
The <<foo>> form is noweb reference syntax. Your example expands the> 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?
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