From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Babel: reusing language-specific functions
Date: Tue, 07 Oct 2014 14:09:50 +0200 [thread overview]
Message-ID: <87zjd884j5.fsf@gmail.com> (raw)
In-Reply-To: 87d2a4w199.fsf@iki.fi
Jarmo Hurri <jarmo.hurri@iki.fi> 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
next prev parent reply other threads:[~2014-10-07 12:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-07 11:46 Babel: reusing language-specific functions Jarmo Hurri
2014-10-07 12:09 ` Thorsten Jolitz [this message]
2014-10-07 16:18 ` Thomas S. Dye
2014-10-09 5:23 ` Jarmo Hurri
2014-10-10 2:11 ` Grant Rettke
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=87zjd884j5.fsf@gmail.com \
--to=tjolitz@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).