2

Using octave in a terminal window

x=1:10;
plot(x);

works fine, produces a plot window which is zoomable etc.

running octave under emacs, the plot appears, but the plot window is hung and you can't zoom. If you execute plot(x); again, the window disappears.

I'm using Debian Jessie, with GNU Emacs 24.3.1 and GNU Octave, version 3.8.1.

To get it to work at all I had to make a .octaverc to set the prompt.

$ cat ~/.octaverc
PS1(">> ")
John Lawrence Aspden
  • 17,124
  • 11
  • 67
  • 110
  • Have you followed the "Appendix H Emacs Octave Support" http://www.gnu.org/software/octave/doc/interpreter/Emacs-Octave-Support.html ? In octave 3.8.1 there is a internal function __fltk_draw__ which keeps the plot figure respondent. This is done by registering with add_input_event_hook within octaves commandline. I'm not an EMacs user but I think the above link addresses this. – Andy Aug 23 '14 at 16:59
  • @Andy, that sounds like a vital clue, but I can't find any reference to this. Can you give me a link? – John Lawrence Aspden Aug 24 '14 at 11:26
  • Doesn't the link above guide you to the HTML page of the manual? – Andy Aug 24 '14 at 11:57
  • @Andy Yes, but there's nothing useful there. I meant a link to this fltk_draw function and its use to keep the plot figure responding. – John Lawrence Aspden Aug 24 '14 at 12:21
  • This bug report? https://bugs.archlinux.org/task/40269 – Andy Aug 24 '14 at 14:09
  • I would suggest asking on the octave help mailinglist, see here http://www.gnu.org/software/octave/support.html. Plenty of octave core developers use Emacs so I think you may get more response there. – Andy Aug 25 '14 at 08:36

1 Answers1

3

It seems that the problem is caused by octave-mode running octave with the no-line-editing switch. You can just hack this out of the compiled lisp file and everything works fine!

On my system:

cd /usr/share/emacs/24.4/lisp/progmodes
sudo vi octave.elc

change --no-line-editing to --line-editing directly in the .elc file

restart emacs and everything should be fine.

John Lawrence Aspden
  • 17,124
  • 11
  • 67
  • 110
  • 2
    This is set with inferior-octave-startup-args, so just run `customize-variable`, make the appropriate change and save for future sessions. No need to edit emacs bytecode. – user2699 Jan 07 '16 at 00:51
  • 1
    This solution freezes emacs until octave is killed. – JoL Aug 12 '21 at 06:04
  • 1
    Found the reason why it froze emacs, and it probably doesn't occur to everyone. Emacs was kept on a loop waiting for octave to print the prompt. Octave did print it but emacs didn't recognize it because it octave didn't start the line with it. It started it with an ANSI escape sequence for terminal bracketed-paste-mode because I had `set enable-bracketed-paste on` in my readline config. One can either remove that from the readline config or edit the prompt regex variable in emacs to fix the freezing. – JoL Aug 13 '21 at 03:22