emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Thomas S. Dye" <tsd@tsdye.com>
To: Lawrence Bottorff <borgauf@gmail.com>
Cc: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: Generate new babel code blocks and/or initialized code/data?
Date: Tue, 20 Sep 2016 09:33:15 -1000	[thread overview]
Message-ID: <m260pqbc3o.fsf@tsdye.com> (raw)
In-Reply-To: <CAFAhFSV7WZavvf5+Oc1R2mLaDSM_DcqU6HT8vQt3ZRNvb8A9Sg@mail.gmail.com>

Aloha Lawrence,

Lawrence Bottorff writes:

> So I can run code for a REPL-type language like Clojure in a babel code
> block and get "results," e.g., a Clojure code block takes in a vector of
> mappings and produces new "results":
>
> #+RESULTS[abc5c51bb569a82c19c4eea1c385c74e839922c7]:
> symmetrize-body-parts-test
> | :name | head            | :size |  3 |
> | :name | left-eye        | :size |  1 |
> | :name | right-eye       | :size |  1 |
> | :name | left-ear        | :size |  1 |
> . . .
>
> but could I generate results that aren't just static output listed after a
> #+RESULTS tag, rather, embedded in a newly created babel code block? I'd
> like such output "initialized" as far as the running REPL is concerned too.
> Is it possible to generate new code/data that is immediately known to the
> REPL session? Any examples don't have to be Clojure.

You can use the :session header argument which will give you access to
any variables created during the session:

http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html#orgheadline13

You can pass the function results to a variable argument, which makes
possible chaining (see http://www.jstatsoft.org/v46/i03):

#+header: :var x=myfunc(2)

You can also embed and call a function in a source code block using noweb
syntax:

http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

  reply	other threads:[~2016-09-20 19:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 19:07 Generate new babel code blocks and/or initialized code/data? Lawrence Bottorff
2016-09-20 19:33 ` Thomas S. Dye [this message]
2016-09-24 20:53   ` Lawrence Bottorff
2016-09-24 21:02     ` Lawrence Bottorff
2016-09-25  0:03     ` Thomas S. Dye
2016-09-25  1:49       ` Lawrence Bottorff
2016-09-25  3:10         ` Thomas S. Dye

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=m260pqbc3o.fsf@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=borgauf@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).