emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel interpreter prompts
@ 2010-02-10 10:52 Rick Moynihan
  2010-02-10 18:44 ` Dan Davison
  0 siblings, 1 reply; 2+ messages in thread
From: Rick Moynihan @ 2010-02-10 10:52 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I'm wondering if it's possible to get org-babel to output the
interpreter prompts and sessions, as if each expression in the src
block had been entered into the repl... e.g. something like:

#+begin_src ruby :output repl
10 + 10
puts "hello world"
[1,2,3,4,5,6,7,8,9,10].map do |i|
  i * i
end
#+end_src

Yielding:

#+results
: irb(main):001:0> 10 + 10
: => 20
: irb(main):002:0> puts "Hello World"
: Hello World
: => nil
: irb(main):003:0> [1,2,3,4,5,6,7,8,9,10].map do |i|
: irb(main):004:1*   i * i
: irb(main):005:1> end
: => [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
: irb(main):006:0>

The rational for this is that it lets you provide examples of being at
the prompt and write better documentation.  I'd imagine that in this
mode, you wouldn't want the original src block to be rendered, rather
just the output as if it had been run interactively.

I'd personally find this useful and would like to see this for ruby,
shell and clojure modes...  Though it'd be nice to have it work for
all the other languages and modes that support a REPL or interactive
prompt too.

-- 
Rick Moynihan
http://twitter.com/RickMoynihan
http://delicious.com/InkyHarmonics
http://sourcesmouth.co.uk/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: org-babel interpreter prompts
  2010-02-10 10:52 org-babel interpreter prompts Rick Moynihan
@ 2010-02-10 18:44 ` Dan Davison
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Davison @ 2010-02-10 18:44 UTC (permalink / raw)
  To: Rick Moynihan; +Cc: emacs-orgmode

Rick Moynihan <rick.moynihan@gmail.com> writes:

> Hi all,
>
> I'm wondering if it's possible to get org-babel to output the
> interpreter prompts and sessions, as if each expression in the src
> block had been entered into the repl... e.g. something like:
>
> #+begin_src ruby :output repl
> 10 + 10
> puts "hello world"
> [1,2,3,4,5,6,7,8,9,10].map do |i|
>   i * i
> end
> #+end_src
>
> Yielding:
>
> #+results
> : irb(main):001:0> 10 + 10
> : => 20
> : irb(main):002:0> puts "Hello World"
> : Hello World
> : => nil
> : irb(main):003:0> [1,2,3,4,5,6,7,8,9,10].map do |i|
> : irb(main):004:1*   i * i
> : irb(main):005:1> end
> : => [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
> : irb(main):006:0>
>
> The rational for this is that it lets you provide examples of being at
> the prompt and write better documentation.  I'd imagine that in this
> mode, you wouldn't want the original src block to be rendered, rather
> just the output as if it had been run interactively.
>
> I'd personally find this useful and would like to see this for ruby,
> shell and clojure modes...  Though it'd be nice to have it work for
> all the other languages and modes that support a REPL or interactive
> prompt too.

Hi Rick,

I believe this should be possible when using :session by altering the
code that processes the output from the comint buffer. I had a quick
attempt at hacking that and failed, as Eric's code in that area is quite
sophisticated for me. (I still don't get how to debug macros.) So over
to Eric.

Note that when not using :session, this effect may still be possible on
a language-by-language basis. For example, with R we can control this
with arguments to the R executable:

~> echo '4+4' | R --vanilla
> 4+4
[1] 8
> 
~> echo '4+4' | R --vanilla --slave
[1] 8
~> 

and so a simple change to org-babel-R.el could introduce user control
over this when using external process evaluation (a.o.t. session).

I don't know whether ruby has something similar. For shell I'm also not
sure. There's bash -x, but that's not quite the same.

So perhaps we could introduce variables called something like
org-babel-ruby-args and org-babel-R-args so that the user can specify
these command line args to external interpreters.

Dan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-10 18:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 10:52 org-babel interpreter prompts Rick Moynihan
2010-02-10 18:44 ` Dan Davison

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).