From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: Babel: reusing language-specific functions Date: Tue, 07 Oct 2014 14:09:50 +0200 Message-ID: <87zjd884j5.fsf@gmail.com> References: <87d2a4w199.fsf@iki.fi> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbTar-0005rm-Tx for emacs-orgmode@gnu.org; Tue, 07 Oct 2014 08:10:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XbTak-0006r8-4L for emacs-orgmode@gnu.org; Tue, 07 Oct 2014 08:10:17 -0400 Received: from plane.gmane.org ([80.91.229.3]:46676) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbTaj-0006qi-Sq for emacs-orgmode@gnu.org; Tue, 07 Oct 2014 08:10:10 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XbTae-0004g5-3H for emacs-orgmode@gnu.org; Tue, 07 Oct 2014 14:10:04 +0200 Received: from g231105110.adsl.alicedsl.de ([92.231.105.110]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 07 Oct 2014 14:10:04 +0200 Received: from tjolitz by g231105110.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 07 Oct 2014 14:10:04 +0200 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@gnu.org Jarmo Hurri writes: > Greetings. > > I have a very basic Babel question, but I can not extract the solution > from the manual. > > I have a language-specific function - in this case Asymptote, but it > could be e.g. C as well - that I want to use in a number of different > source blocks of the same language in an Org file. How do I accomplish > this? > > Currently my solution is to write the function into an external source > file, and include the file in the source blocks. But that looks ugly, > and is sort of against the Org-mode way of doing things: all code in the > same place for completeness and convenience. > > How can I achieve what I want? try something like this: #+NAME: foo #+BEGIN_SRC emacs-lisp (defun foo (x) (+ x 2)) #+END_SRC #+results: foo : foo #+BEGIN_SRC emacs-lisp :var fun=foo (funcall (intern fun) 3) #+END_SRC #+results: : 5 -- cheers, Thorsten