emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] noweb and results for ob-screen?
       [not found] <CAPaq-gOhsRRwEiu6GqkphpsqdQDAuOQ2WBK24h-16a+o25Tw1A@mail.gmail.com>
@ 2011-12-17  9:38 ` Torsten Wagner
  2011-12-19 11:18   ` Torsten Wagner
  2011-12-22 15:08   ` Eric S Fraga
  0 siblings, 2 replies; 5+ messages in thread
From: Torsten Wagner @ 2011-12-17  9:38 UTC (permalink / raw)
  To: Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 526 bytes --]

Hi,
recently I discovered babel in combination with screen. I really like it.
However, I tried to use noweb but it seems not to work.  Getting it working
would allow to write "tasks" and arbitrary combine them to bigger tasks.

I would be interested in results too.  Would be nice to receive some
feedback from above tasks.  Thus, one could document the success or
results.  For now I have to copy results from the screen terminal which is
kind of error prone.

Any chance to enhance ob-screen with the above features?

Totti

[-- Attachment #2: Type: text/html, Size: 582 bytes --]

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

* Re: [babel] noweb and results for ob-screen?
  2011-12-17  9:38 ` [babel] noweb and results for ob-screen? Torsten Wagner
@ 2011-12-19 11:18   ` Torsten Wagner
  2011-12-22 15:08   ` Eric S Fraga
  1 sibling, 0 replies; 5+ messages in thread
From: Torsten Wagner @ 2011-12-19 11:18 UTC (permalink / raw)
  To: Org Mode Mailing List

Hmmm...

I looked a bit into it and it seems screen can log the session into a 
file. org-mode could read the total number of lines of that file before 
executing a new block of the same session and add the number of line 
feeds for the executed source code block. Hence, we would know at which 
point the "result" would start.
However, this would add the entire output of the source code block as 
result.
One could limit the result to the last send command by the above method 
too. Just splitting the source code block internally into two parts. The 
first one contains all but the last command, the second contains only 
the last command.

As for noweb, I can't see from the source code why it should not work. 
Does someone have an idea about that. I gave names to all my source code 
blocks. Then I defined a source code block with the header argument 
:noweb true. However all <<names>> lines are send to screen instead of 
the content of so called source code blocks.

I also looked into variables. However, this seems to be a bit tricky, 
the problem is screen runs interactively, hence, you could run all kind 
of other stuff in the screen session, e.g., python, emacs, a serial 
terminal, etc. . How could org-mode know if it has to warp the variable 
according to python-, shell-, lisp- or any other syntax.

Might it be possible (and does it make sense) to simply enable some kind 
of macro-like replacement. E.g.
:var _X_=3
would replace all _X_ by 3. There would be no formal syntax and no 
format rules. Just a simple greedy search and replace. Thus, the user 
can/have to think by himself how a variable name would have to look like 
to get no conflict with the target language.
E.g.
:var var=12
could be a bad idea if the source code would be
test = var
var2 = 12
def variant():

because it would be replaced by

test = 12
122 = 12
def 12iant():

We could not rely on spaces around variables because some languages 
might not allow spaces. That is

test=12 can not be written test = 12

However, source code blocks are normally relatively small and the user 
could use any kind of scheme which makes a distinction with the target 
language within screen easy (using all kind of seldom used characters 
_,%,#, etc.)

Any thoughts or ideas?

I really like the interactive screen functionality which allows me to 
perform all kind of tasks interactively within a screen session.

Torsten


On 12/17/2011 06:38 PM, Torsten Wagner wrote:
> Hi,
> recently I discovered babel in combination with screen. I really like it.
> However, I tried to use noweb but it seems not to work.  Getting it working
> would allow to write "tasks" and arbitrary combine them to bigger tasks.
>
> I would be interested in results too.  Would be nice to receive some
> feedback from above tasks.  Thus, one could document the success or
> results.  For now I have to copy results from the screen terminal which is
> kind of error prone.
>
> Any chance to enhance ob-screen with the above features?
>
> Totti
>

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

* Re: [babel] noweb and results for ob-screen?
  2011-12-17  9:38 ` [babel] noweb and results for ob-screen? Torsten Wagner
  2011-12-19 11:18   ` Torsten Wagner
@ 2011-12-22 15:08   ` Eric S Fraga
  2011-12-23 14:16     ` Torsten Wagner
  1 sibling, 1 reply; 5+ messages in thread
From: Eric S Fraga @ 2011-12-22 15:08 UTC (permalink / raw)
  To: Torsten Wagner; +Cc: Org Mode Mailing List

Torsten Wagner <torsten.wagner@gmail.com> writes:

> Hi,
> recently I discovered babel in combination with screen. I really like it.
> However, I tried to use noweb but it seems not to work.  Getting it working
> would allow to write "tasks" and arbitrary combine them to bigger tasks.
>
> I would be interested in results too.  Would be nice to receive some
> feedback from above tasks.  Thus, one could document the success or
> results.  For now I have to copy results from the screen terminal which is
> kind of error prone.
>
> Any chance to enhance ob-screen with the above features?
>
> Totti

I have never tried the screen support in babel although I do use screen
all the time on my smaller devices (Nokia N900, for instance) and for
remote clusters etc.

However, for shell scripting, I have always used ob-sh.  What do you
gain from that isn't possible with ob-sh?  Just curious in case I am
missing some very useful functionality!

Thanks,
eric

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.90.1
: using Org-mode version 7.8.02 (release_7.8.02.26.g314e)

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

* Re: [babel] noweb and results for ob-screen?
  2011-12-22 15:08   ` Eric S Fraga
@ 2011-12-23 14:16     ` Torsten Wagner
  2011-12-30 12:56       ` Eric S Fraga
  0 siblings, 1 reply; 5+ messages in thread
From: Torsten Wagner @ 2011-12-23 14:16 UTC (permalink / raw)
  To: Torsten Wagner, Org Mode Mailing List

Hi Eric,

thanks for pushing this up :)
Well as far as I understood, ob-sh is at the final end (after
org-babel did its job) a shell script which will be executed.
ob-screen is an interactive connection to a screen session. Everything
inside the source cgode block will be sent to this session.
This is not limited to terminal commands, but could e.g., be
keystrokes for a ncurse based program, a serial terminal, etc.
Furthermore all is send over "as-it-is"
Thus you could have different code blocks and concatenate them to
complex commands.

E.g., (not complex but for demo ;) )

#+src_name copy
#+begin_src screen :session copy
cp -ar
#+end_src

#+src_name source1
#+begin_src screen :session copy
~/data
#+end_src

#+src_name source2
#+begin_src screen :session copy
~/picture
#+end_src

#+src_name target1
#+begin_src screen :session copy
/media/sdb1

#+end_src

#+src_name target2
#+begin_src screen :session copy
/media/sdb2

#+end_src

Now you could call the code-blocks in the desired combination to create e.g.
cp -ar ~/data /media/sdb1
or
cp -ar ~/picture /media/sdb2
etc.

Please note that the target blocks contain an empty line to send over
a carriage return and hence start the final command in the screen
session.

Guess you could easily think of far more complex examples.
The screen session is running parallel in an window beside emacs
(guess it might be even possible to run it within emacs by e.g.
eshell).
Thus it is perfect to augmented the tasks.

Unfortunately, ob-screen seems to have no idea of variables and
results. Furthermore, I did not get noweb working but did not see why
it should not work.

At the moment I try to use it to open a serial terminal and talk to an
measurement device.
I can easily send over the commands necessary to talk to the device,
but having noweb would allow me to combine different commands into
small scripts. Like

<<open_device>>
<<set-up_device>>
<<read_measurement>>
<<close_device>>
Each of those might contain many lines of cryptic ASCII characters and numbers

You can try

#+src_name start_emacs
#+begin_src screen :session emacs
emacs -nw

#+end_src

#+src_name hello_emacs_world
#+begin_src screen :session emacs
Hello Emacs World !!!!

#+end_src

Hope you get the idea :D

Now imagine if you could send in variables, get results and being able
to put different code blocks together.


Torsten

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

* Re: [babel] noweb and results for ob-screen?
  2011-12-23 14:16     ` Torsten Wagner
@ 2011-12-30 12:56       ` Eric S Fraga
  0 siblings, 0 replies; 5+ messages in thread
From: Eric S Fraga @ 2011-12-30 12:56 UTC (permalink / raw)
  To: Torsten Wagner; +Cc: Org Mode Mailing List

Torsten Wagner <torsten.wagner@gmail.com> writes:

> Hi Eric,
>
> thanks for pushing this up :)
> Well as far as I understood, ob-sh is at the final end (after
> org-babel did its job) a shell script which will be executed.
> ob-screen is an interactive connection to a screen session. Everything
> inside the source cgode block will be sent to this session.
> This is not limited to terminal commands, but could e.g., be
> keystrokes for a ncurse based program, a serial terminal, etc.
> Furthermore all is send over "as-it-is"
> Thus you could have different code blocks and concatenate them to
> complex commands.

[...]

> Hope you get the idea :D

I do indeed!  Thanks.  Very helpful description of what could be
done.  I guess I was definitely stuck in the shell script mode.

eric
-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.92.1
: using Org-mode version 7.8.02 (release_7.8.02.55.g1870)

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

end of thread, other threads:[~2011-12-30 12:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAPaq-gOhsRRwEiu6GqkphpsqdQDAuOQ2WBK24h-16a+o25Tw1A@mail.gmail.com>
2011-12-17  9:38 ` [babel] noweb and results for ob-screen? Torsten Wagner
2011-12-19 11:18   ` Torsten Wagner
2011-12-22 15:08   ` Eric S Fraga
2011-12-23 14:16     ` Torsten Wagner
2011-12-30 12:56       ` Eric S Fraga

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