emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel: interactive terminal support
@ 2009-09-23  1:11 Benjamin Andresen
  2009-09-23 23:02 ` Eric Schulte
  2009-09-25 23:02 ` Dan Davison
  0 siblings, 2 replies; 7+ messages in thread
From: Benjamin Andresen @ 2009-09-23  1:11 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

after seeing org-babel I immediately thought of the eev project by
Eduardo Ochs (http://angg.twu.net/)

Basically I wanted to do what he does in this video:
http://angg.twu.net/eev-current/anim/channels.anim.html

So I wrote a small org-babel gnu screen interface.
Eev does the same with "expect" but is very line-centric. And GNU Screen
can slurp in whole files. (I guess one could support several backends if
this proves useful)

The translated org-babel syntax looks like this:

* Listen on port 1234
  #+begin_src screen :session receiver :results silent
    netcat -l -p 1234
  #+end_src

* Send things to port 1234
  #+begin_src screen :session sender :results silent
    {   
     echo hi
     sleep 1
     echo bye 
     sleep 1
    } | netcat -c localhost 1234
  #+end_src

I've put the code on github if anyone is interested in this:
http://github.com/bandresen/org-babel-screen

A few things are still hardcoded, like the use of /bin/zsh. If you guys
think this is a worthwhile addition to org-babel, let me know what the
right parameter would be.

HTH,
benny

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

* Re: org-babel: interactive terminal support
  2009-09-23  1:11 org-babel: interactive terminal support Benjamin Andresen
@ 2009-09-23 23:02 ` Eric Schulte
  2009-09-23 23:46   ` Benjamin Andresen
  2009-09-25 23:02 ` Dan Davison
  1 sibling, 1 reply; 7+ messages in thread
From: Eric Schulte @ 2009-09-23 23:02 UTC (permalink / raw)
  To: Benjamin Andresen; +Cc: emacs-orgmode

Benjamin Andresen <benny@in-ulm.de> writes:

> Hello,
>
> after seeing org-babel I immediately thought of the eev project by
> Eduardo Ochs (http://angg.twu.net/)
>
> Basically I wanted to do what he does in this video:
> http://angg.twu.net/eev-current/anim/channels.anim.html
>

So if I understand the purpose is to evaluate source-code blocks in
Org-mode files which will open terminals in new windows, send shell
commands to those terminals, and either display information in the
terminals and possible insert output from those terminals into Org-mode
buffers?

I like the idea, however I can't get it working on my Mac.  I am able to
pop open new xterms, however nothing seems to make it into or out of
screen (maybe this is because I all ways have screen running as my
normal terminal emulator?).

Unfortunately I'm *really* short on time right now, but I hope to take a
closer look when I get a chance...

>
> So I wrote a small org-babel gnu screen interface.
> Eev does the same with "expect" but is very line-centric. And GNU Screen
> can slurp in whole files. (I guess one could support several backends if
> this proves useful)
>
> The translated org-babel syntax looks like this:
>
> * Listen on port 1234
>   #+begin_src screen :session receiver :results silent
>     netcat -l -p 1234
>   #+end_src
>
> * Send things to port 1234
>   #+begin_src screen :session sender :results silent
>     {   
>      echo hi
>      sleep 1
>      echo bye 
>      sleep 1
>     } | netcat -c localhost 1234
>   #+end_src
>
> I've put the code on github if anyone is interested in this:
> http://github.com/bandresen/org-babel-screen
>
> A few things are still hardcoded, like the use of /bin/zsh. If you guys
> think this is a worthwhile addition to org-babel

Yes, the code looks clean, and it looks like it would provide a new type
of functionality (live terminal output?) so I'd be very happy to include
this into Org-babel.

>, let me know what the
> right parameter would be.
>

I don't see where you have /bin/zsh hard-coded...

Thanks! -- Eric

>
> HTH,
> benny
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: org-babel: interactive terminal support
  2009-09-23 23:02 ` Eric Schulte
@ 2009-09-23 23:46   ` Benjamin Andresen
  0 siblings, 0 replies; 7+ messages in thread
From: Benjamin Andresen @ 2009-09-23 23:46 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

Hey Eric,

"Eric Schulte" <schulte.eric@gmail.com> writes:

> Benjamin Andresen <benny@in-ulm.de> writes:
>
> So if I understand the purpose is to evaluate source-code blocks in
> Org-mode files which will open terminals in new windows, send shell
> commands to those terminals, and either display information in the
> terminals and possible insert output from those terminals into Org-mode
> buffers?
The first part is correct. It will open different terminals depending on
the amount of sessions specified and run the code in the source-code
blocks.

It's only a one-way street at the moment though, the resulting output is
currently dismissed. (But possible to get, depending on what
shell/config is used. screen's hardcopy.)

> I like the idea, however I can't get it working on my Mac.  I am able to
> pop open new xterms, however nothing seems to make it into or out of
> screen (maybe this is because I all ways have screen running as my
> normal terminal emulator?).

Nope, that shouldn't have anything to do with it. I also have screen
running at all times. It's creating a new screen instance for every
session. The sockets are named org-babel-session-$SESSION.

The problem might be in line 49, because I hard-coded a one second sleep
timer in there to only send the resulting source code block afterward.
(To give xterm and screen a time to spawn.)

That's pretty dirty and I should fix that.

> I don't see where you have /bin/zsh hard-coded...

That's because my mail was sent before I had a look around how other
modes handle parameter. Now it's defaulting to "sh" but it can be
changed with :cmd

> Thanks! -- Eric
>

br,
benny

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

* Re: org-babel: interactive terminal support
  2009-09-23  1:11 org-babel: interactive terminal support Benjamin Andresen
  2009-09-23 23:02 ` Eric Schulte
@ 2009-09-25 23:02 ` Dan Davison
  2009-09-25 23:29   ` Benjamin Andresen
  1 sibling, 1 reply; 7+ messages in thread
From: Dan Davison @ 2009-09-25 23:02 UTC (permalink / raw)
  To: Benjamin Andresen; +Cc: emacs-orgmode

Benjamin Andresen <benny@in-ulm.de> writes:

> Hello,
>
> after seeing org-babel I immediately thought of the eev project by
> Eduardo Ochs (http://angg.twu.net/)
>
> Basically I wanted to do what he does in this video:
> http://angg.twu.net/eev-current/anim/channels.anim.html
>
> So I wrote a small org-babel gnu screen interface.
> Eev does the same with "expect" but is very line-centric. And GNU Screen
> can slurp in whole files. (I guess one could support several backends if
> this proves useful)

Hi Benny,

This looks very interesting and I think it's extremely likely that we'll
want to include your code -- thanks very much. Having said that, I'm
being a bit dense: would you mind expanding a bit on what this currently
does, and what it has the potential to do?

Dan

>
> The translated org-babel syntax looks like this:
>
> * Listen on port 1234
>   #+begin_src screen :session receiver :results silent
>     netcat -l -p 1234
>   #+end_src
>
> * Send things to port 1234
>   #+begin_src screen :session sender :results silent
>     {   
>      echo hi
>      sleep 1
>      echo bye 
>      sleep 1
>     } | netcat -c localhost 1234
>   #+end_src
>
> I've put the code on github if anyone is interested in this:
> http://github.com/bandresen/org-babel-screen
>
> A few things are still hardcoded, like the use of /bin/zsh. If you guys
> think this is a worthwhile addition to org-babel, let me know what the
> right parameter would be.
>
> HTH,
> benny
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: org-babel: interactive terminal support
  2009-09-25 23:02 ` Dan Davison
@ 2009-09-25 23:29   ` Benjamin Andresen
  2009-09-28 19:55     ` Dan Davison
  0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Andresen @ 2009-09-25 23:29 UTC (permalink / raw)
  To: emacs-orgmode

Hey Dan,

Dan Davison <davison@stats.ox.ac.uk> writes:

> Hi Benny,
>
> This looks very interesting and I think it's extremely likely that we'll
> want to include your code -- thanks very much. Having said that, I'm
> being a bit dense: would you mind expanding a bit on what this currently
> does, and what it has the potential to do?

All it currently does it show you a terminal which gets the source
code block send to. Just like an inferior process.

I've made a gif of the channels.org example from my first mail:
http://github.com/bandresen/org-babel-screen/blob/master/channels.anim.gif

The way I currently see it, it somehow works as an interactive makefile.

An example of a use that I have is that want to extract several frames
out of a video file and convert them to a gif animation.

It's a commented org file with several steps such as:

* find the part you want to extract
#+begin_src screen :session create-gif
  mplayer -ao null -osdlevel 3 /tmp/videofile.avi 
#+end_src
[...snip...]
* convert selected frames to gif
#+begin_src screen :session create-gif
  convert -delay 100 -loop 0 .qiv-select/* animation.gif
#+end_src

I don't know how useful it is to other people, but because it basically
gives you the power over a terminal emulator you could do anything in it
that you can do in a normal terminal. Except better controlled and
documented.

Or one could use a standardized notation for keypresses and let screen
translate them for you. Example:

#+begin_src screen :session vimtutorial
  vimtutor
  85G
  fcx
  EEx
  llx
  ^Vjjjjlllx
#+end_src

Which might be useful in some way.

Another thing that might be possible is to simulate an 'expect' like
behavior by using screen's capability to dump the output of commands.
It's certainly possible, but replacing an app like 'expect' is no small
task. :-)

br,
benny

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

* Re: Re: org-babel: interactive terminal support
  2009-09-25 23:29   ` Benjamin Andresen
@ 2009-09-28 19:55     ` Dan Davison
  2009-09-28 20:36       ` Benjamin Andresen
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Davison @ 2009-09-28 19:55 UTC (permalink / raw)
  To: Benjamin Andresen; +Cc: emacs-orgmode

Benjamin Andresen <benny@in-ulm.de> writes:

> Hey Dan,
>
> Dan Davison <davison@stats.ox.ac.uk> writes:
>
>> Hi Benny,
>>
>> This looks very interesting and I think it's extremely likely that we'll
>> want to include your code -- thanks very much. Having said that, I'm
>> being a bit dense: would you mind expanding a bit on what this currently
>> does, and what it has the potential to do?
>
> All it currently does it show you a terminal which gets the source
> code block send to. Just like an inferior process.

Hi Benny,

Thanks a lot for that, it looks really promising. Do you want to create
a branch in a publicly accessible org-mode repo containing your
additions?  I've created an org mode fork for org-babel development at

git://repo.or.cz/org-mode/babel.git

webpage

http://repo.or.cz/w/org-mode/babel.git

which you could use (I'll send you the admin password offline so you can
give yourself push rights).

Dan

>
> I've made a gif of the channels.org example from my first mail:
> http://github.com/bandresen/org-babel-screen/blob/master/channels.anim.gif
>
> The way I currently see it, it somehow works as an interactive makefile.
>
> An example of a use that I have is that want to extract several frames
> out of a video file and convert them to a gif animation.
>
> It's a commented org file with several steps such as:
>
> * find the part you want to extract
> #+begin_src screen :session create-gif
>   mplayer -ao null -osdlevel 3 /tmp/videofile.avi 
> #+end_src
> [...snip...]
> * convert selected frames to gif
> #+begin_src screen :session create-gif
>   convert -delay 100 -loop 0 .qiv-select/* animation.gif
> #+end_src
>
> I don't know how useful it is to other people, but because it basically
> gives you the power over a terminal emulator you could do anything in it
> that you can do in a normal terminal. Except better controlled and
> documented.
>
> Or one could use a standardized notation for keypresses and let screen
> translate them for you. Example:
>
> #+begin_src screen :session vimtutorial
>   vimtutor
>   85G
>   fcx
>   EEx
>   llx
>   ^Vjjjjlllx
> #+end_src
>
> Which might be useful in some way.
>
> Another thing that might be possible is to simulate an 'expect' like
> behavior by using screen's capability to dump the output of commands.
> It's certainly possible, but replacing an app like 'expect' is no small
> task. :-)





>
> br,
> benny
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: org-babel: interactive terminal support
  2009-09-28 19:55     ` Dan Davison
@ 2009-09-28 20:36       ` Benjamin Andresen
  0 siblings, 0 replies; 7+ messages in thread
From: Benjamin Andresen @ 2009-09-28 20:36 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

Dan Davison <davison@stats.ox.ac.uk> writes:

> Hi Benny,
>
> Thanks a lot for that, it looks really promising. Do you want to create
> a branch in a publicly accessible org-mode repo containing your
> additions?

Sure.

Should it really be a branch? At the moment it's a single file just like
the others that are located in langs/

I could create some examples (like the channels.org one) on a seperate
Worg page.

> I've created an org mode fork for org-babel development at
>
> git://repo.or.cz/org-mode/babel.git
>
> webpage
>
> http://repo.or.cz/w/org-mode/babel.git
>
> which you could use (I'll send you the admin password offline so you can
> give yourself push rights).
>
> Dan

br,
benny

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

end of thread, other threads:[~2009-09-28 20:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-23  1:11 org-babel: interactive terminal support Benjamin Andresen
2009-09-23 23:02 ` Eric Schulte
2009-09-23 23:46   ` Benjamin Andresen
2009-09-25 23:02 ` Dan Davison
2009-09-25 23:29   ` Benjamin Andresen
2009-09-28 19:55     ` Dan Davison
2009-09-28 20:36       ` Benjamin Andresen

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