Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Testing terminal programs within emacs (SOLVED)

by LanX (Saint)
on Nov 29, 2014 at 21:41 UTC ( [id://1108752]=note: print w/replies, xml ) Need Help??


in reply to Testing terminal programs within emacs (or other IDEs)

> Term::ReadLine allows defining explicit IN and OUT handles which may be redirected to a separate xterm window?

tried this but wasn't sufficiently reliable, (but this couldhave been be caused by gnome-terminal weirdness)

The following hack works with xterm , put it at the very beginning of your program.

It restarts the program within a separate xterm-window but redirects STDERR to the parent process.

This allows running a terminal script from within emacs and should be easily adapted to other environments using l/unix.

All STDERR warnings show within emacs and are clickable to navigate to source file/line.

my $ptty=$ARGV[0]; if ($ENV{INSIDE_EMACS}) { my $tty=`tty`; delete $ENV{INSIDE_EMACS}; warn "restart in xterm $0 $tty\n"; my $x=`xterm -e '/usr/bin/perl $0 $tty'`; warn "xterm closed\n"; exit; } elsif ($ptty) { close STDERR; open STDERR,">",$ptty; local $\="\n"; warn "redirecting STDERR to $ptty\n"; $|=1; }

This approach can also be used by the perldebugger when debugging another Term::ReadLine application

When sufficiently tested this logic can be put into a separate module RunXTerm , no adjustments of editor needed.

disclaimer
It's a proof of concept hack!!!

I'm not overly familiar with tty and forking and open for cleaner suggestions. :)

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1108752]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 11:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found