Octave mode provides commands for running an inferior Octave process in a special Emacs buffer. Use
to directly start an inferior Octave process.
This will start Octave in a special buffer the name of which is
specified by the variable
inferior-octave-buffer and defaults
to *Inferior Octave*. From within this buffer, you can
interact with the inferior Octave process “as usual”, i.e., by
entering Octave commands at the prompt. The buffer is in Inferior
Octave mode, which is derived from the standard Comint mode, a major
mode for interacting with an inferior interpreter. See the
comint-mode for more details, and use
C-h b to find out about available special keybindings.
You can also communicate with an inferior Octave process from within files with Octave code (i.e., buffers in Octave mode), using the following commands.
Send the current line to the inferior Octave process
octave-send-line). With positive prefix argument n,
send that many lines. If
nil, go to the next unsent code line.
Send the current block to the inferior Octave process
Send the current function to the inferior Octave process
Send the region to the inferior Octave process
Send the entire buffer to the inferior Octave process
octave-send-buffer). If the buffer is associated with a file
then sourcing the buffer by using C-c C-l
octave-source-file) should be preferred.
Make sure that
inferior-octave-buffer is displayed
Delete all windows that display the inferior Octave buffer
Kill the inferior Octave process and its buffer
Parse and execute the current file in the inferior Octave buffer
octave-source-file). This is done using Octave’s
Find the definition of a function or variable. Functions implemented
in C++ can be found if variable
set correctly (
Display the documentation for function (
buffer name can be changed by customizing
Search for a given string in all the first sentence of function help
octave-lookfor). With a
entire help string is searched.
The effect of the commands which send code to the Octave process can be customized by the following variables.
nil means echo input sent to the inferior Octave process.
nil means display the buffer running the Octave process after
sending a command (but without selecting it).
If you send code and there is no inferior Octave process yet, it will be started automatically.
The startup of the inferior Octave process is highly customizable.
inferior-octave-startup-args can be used for
specifying command lines arguments to be passed to Octave on startup
as a list of strings. For example, to suppress the startup message
and use “traditional” mode, set this to
You can also specify a startup file of Octave commands to be loaded on
startup; note that these commands will not produce any visible output
in the process buffer. Which file to use is controlled by the
inferior-octave-startup-file. The default is
~/.emacs-octave or if this file is not found
inferior-octave-prompt-read-only the prompt can
be changed to be read only. The default value is the same as
inferior-octave-mode-hook is run after starting
the process and putting its buffer into Inferior Octave mode. Hence,
if you like the up and down arrow keys to behave in the interaction
buffer as in the shell, and you want this buffer to use nice colors,
(add-hook 'inferior-octave-mode-hook (lambda () (define-key inferior-octave-mode-map [up] 'comint-previous-input) (define-key inferior-octave-mode-map [down] 'comint-next-input)))
to your .emacs or init.el file. You could also swap the
roles of C-a (
comint-bol) using this hook.
Note that if you set your Octave prompts to something different from the defaults, make sure that
inferior-octave-promptmatches them. Otherwise, nothing will work, because Emacs will not know when Octave is waiting for input, or done sending output.