External editor

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

External editor

Krzysztof Gozdziewski

Hello !

I have a problem with calling an external editor from within a session
of octave. If I try to define a command like

    ed = system( "joe", "myfun.m" )

the editor 'joe' hangs the session at the start and I have to kill
the process of octave. The same is with vi.

We use octave on SunOS4.1.3 and 5.3, the shell is tcsh.

Sorry if I overlooked a strightforward solution to this problem.
If someone knows it please replay. I need the editor for
writing function and program files when having only one text terminal.

Thanks in advance.
With best regards

Krzysztof Gozdziewski
---------------------------------   ^-^   ~~~ Krzysztof Go\'zdziewski
                                   (* *)  ~~~ Institute of Astronomy
                                   ==*==  ~~~ Nicolaus Copernicus University
                                    /?\   ~~~ Chopina Str 12/18
                                   (m_m)  ~~~ PL-87-100 Toru\'n POLAND
   

Reply | Threaded
Open this post in threaded view
|

Re: External editor

Vinayak Dutt
#
#Hello !
#
#I have a problem with calling an external editor from within a session
#of octave. If I try to define a command like
#
#    ed = system( "joe", "myfun.m" )
#
#the editor 'joe' hangs the session at the start and I have to kill
#the process of octave. The same is with vi.
#
#We use octave on SunOS4.1.3 and 5.3, the shell is tcsh.
#

 i don't think system() command will work with interactive processes.
at least it did not work for me either on SunOS4.1.3 using vi. maybe
octave takes over the terminal which vi is unable to take over ??

also the usage should be:

ed = system("joe myfun.m")

but the question, is why do you have to run editor from within octave?

you could very well suspend the octave process with ^Z (control-Z), do
your editing, and then resume octave with command "fg".

(or if you are like working in an X window environment, run editor
is another window all together :-)

--vinayak-
/*
 * vinayak dutt
 * graduate student, ultrasound research
 * mayo graduate school, rochester mn
 *
 * e-mail: [hidden email]
 *         [hidden email]
 *
 */
#include "disclaimer.h"

Reply | Threaded
Open this post in threaded view
|

Re: External editor

John Eaton-4
In reply to this post by Krzysztof Gozdziewski
[hidden email] (Krzysztof Gozdziewski) wrote:

: I have a problem with calling an external editor from within a session
: of octave. If I try to define a command like
:
:     ed = system( "joe", "myfun.m" )
:
: the editor 'joe' hangs the session at the start and I have to kill
: the process of octave. The same is with vi.

This is from the manual distributed with 1.1.0:

   If you want to execute a shell command and have it behave as if it
   were typed directly from the shell prompt, you may need to specify
   extra arguments for the command.  For example, to get `bash' to
   behave as an interactive shell, you can type

     system ("bash -i >/dev/tty");

   The first argument, `-i', tells `bash' to behave as an interactive
   shell, and the redirection of the standard output stream prevents
   any output produced by `bash' from being sent back to Octave, where
   it would be buffered until Octave displays another prompt.


So, I think it might work to do something like

    function ed (file)
    system (["joe ", file, " >/dev/tty"]);
    endfunction

Of course, this could be improved by checking the argument to make
sure it exists and is a string, etc.

You might also want to look at the edit_history command, which will
start the editor for you on a list of previous commands from Octave's
history list.

: We use octave on SunOS4.1.3 and 5.3, the shell is tcsh.
:
: Sorry if I overlooked a strightforward solution to this problem.
: If someone knows it please replay. I need the editor for
: writing function and program files when having only one text terminal.

On Sun systems with tcsh you should be able to use job control to
suspend Octave while you edit and restart it when you are ready to go
on.  Is there some reason this doesn't work properly for you?

jwe