emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Babel: reusing language-specific functions


From: Thorsten Jolitz
Subject: Re: [O] Babel: reusing language-specific functions
Date: Tue, 07 Oct 2014 14:09:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Jarmo Hurri <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]