Next: Running Octave from Within Emacs, Previous: Overview, Up: Top [Contents][Index]

## 2 Using Octave Mode

In Octave mode, the following special Emacs commands can be used in addition to the standard Emacs commands.

`C-M-j`

  Break Octave line at point, continuing comment if within one. Insert `octave-continuation-string` before breaking the line unless inside a list. Signal an error if within a single-quoted string.

`C-c ;`

  Query replace function names in function file comment.

`C-c C-p`

  Move one line of Octave code backward, skipping empty and comment lines (`octave-previous-code-line`). With numeric prefix argument n, move that many code lines backward (forward if n is negative).

`C-c C-n`

  Move one line of Octave code forward, skipping empty and comment lines (`octave-next-code-line`). With numeric prefix argument n, move that many code lines forward (backward if n is negative).

`C-c C-a`

  Move to the beginning of the physical line (`octave-beginning-of-line`). If point is in an empty or comment line, simply go to its beginning; otherwise, move backwards to the beginning of the first code line which is not inside a continuation statement, i.e., which does not follow a code line ending in ‘`...`’ or ‘`\`’, or is inside an open parenthesis list.

`C-c C-e`

  Move to the end of the physical line (`octave-end-of-line`). If point is in a code line, move forward to the end of the first Octave code line which does not end in ‘`...`’ or ‘`\`’ or is inside an open parenthesis list. Otherwise, simply go to the end of the current line.

`C-c M-C-h`

  Put point at the beginning of this block, mark at the end (`octave-mark-block`). The block marked is the one that contains point or follows point.

`C-c ]`

  Close the current block on a separate line (`smie-close-block`). An error is signaled if no block to close is found.

`C-c C-f`

  Insert a function skeleton, prompting for the function’s name, arguments and return values which have to be entered without parentheses (`octave-insert-defun`). in one of your Emacs startup files.

The following variables can be used to customize Octave mode.

`octave-blink-matching-block`

  Non-`nil` means show matching begin of block when inserting a space, newline or ‘`;`’ after an else or end keyword. Default is `t`. This is an extremely useful feature for automatically verifying that the keywords match—if they don’t, an error message is displayed.

`octave-block-offset`

  Extra indentation applied to statements in block structures. Default is 2.

`octave-continuation-offset`

  Extra indentation applied to Octave continuation lines. Default is 4.

`octave-font-lock-texinfo-comment`

  Highlight texinfo comment blocks. The default value is `t`.

If Font Lock mode is enabled, Octave mode will display

- strings in `font-lock-string-face`
- comments in `font-lock-comment-face`
- the Octave reserved words (such as all block keywords) and the text functions (such as ‘`cd`’ or ‘`who`’) which are also reserved using `font-lock-keyword-face`
- the built-in operators (‘`&&`’, ‘`==`’, …) using `font-lock-reference-face`
- and the function names in function declarations in `font-lock-function-name-face`.
- Function comments blocks in `octave-function-comment-block`

There is also rudimentary support for Imenu (see Imenu in The GNU Emacs Manual). Currently, function names can be indexed.

ElDoc mode (see Lisp Doc in The GNU Emacs Manual) is supported. By customizing `octave-eldoc-message-style` it can be changed from displaying one or multi line hints.

Customization of Octave mode can be performed by modification of the variable `octave-mode-hook`.

Next: Running Octave from Within Emacs, Previous: Overview, Up: Top [Contents][Index]