From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas S. Dye Subject: Re: babel srcname? Calling Library of Babel code? Date: Mon, 05 Oct 2015 19:15:27 -1000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjLCI-0003cq-0O for emacs-orgmode@gnu.org; Tue, 06 Oct 2015 01:53:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjLCE-00028M-Qf for emacs-orgmode@gnu.org; Tue, 06 Oct 2015 01:53:57 -0400 Received: from gproxy6-pub.mail.unifiedlayer.com ([67.222.39.168]:50085) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1ZjLCE-00021g-JU for emacs-orgmode@gnu.org; Tue, 06 Oct 2015 01:53:54 -0400 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: Lawrence Bottorff Cc: emacs-orgmode Mailinglist 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