Function: octave-mode

octave-mode is an autoloaded, interactive and byte-compiled function defined in octave.el.gz.

Signature

(octave-mode)

Documentation

Major mode for editing Octave code.

Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and nonlinear problems numerically. Function definitions can also be stored in files and used in batch mode.

See Info node (octave-mode) Using Octave Mode for more details.

Key bindings:
C-M-d smie-down-list
C-M-j octave-indent-new-comment-line
C-c / smie-close-block
C-c ; octave-update-function-file-comment
C-c C-M-h octave-mark-block
C-c C-a octave-beginning-of-line
C-c C-e octave-end-of-line
C-c C-f octave-insert-defun
C-c C-l octave-source-file
C-c C-n octave-next-code-line
C-c C-p octave-previous-code-line
C-c TAB C-a octave-send-buffer
C-c TAB C-b octave-send-block
C-c TAB C-f octave-send-defun
C-c TAB C-k octave-kill-process
C-c TAB C-l octave-send-line
C-c TAB C-q octave-hide-process-buffer
C-c TAB C-r octave-send-region
C-c TAB C-s octave-show-process-buffer
C-c TAB a octave-send-buffer
C-c TAB b octave-send-block
C-c TAB f octave-send-defun
C-c TAB k octave-kill-process
C-c TAB l octave-send-line
C-c TAB q octave-hide-process-buffer
C-c TAB r octave-send-region
C-c TAB s octave-show-process-buffer
C-c ] smie-close-block
C-h a octave-lookfor
C-h d octave-help
M-. octave-find-definition

In addition to any hooks its parent mode prog-mode might have run, this mode runs the hook octave-mode-hook, as the final or penultimate step during initialization.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/octave.el.gz
;;;###autoload
(define-derived-mode octave-mode prog-mode "Octave"
  "Major mode for editing Octave code.

Octave is a high-level language, primarily intended for numerical
computations.  It provides a convenient command line interface
for solving linear and nonlinear problems numerically.  Function
definitions can also be stored in files and used in batch mode.

See Info node `(octave-mode) Using Octave Mode' for more details.

Key bindings:
\\{octave-mode-map}"
  :abbrev-table octave-abbrev-table
  :group 'octave

  (smie-setup octave-smie-grammar #'octave-smie-rules
              :forward-token  #'octave-smie-forward-token
              :backward-token #'octave-smie-backward-token)
  (setq-local smie-indent-basic 'octave-block-offset)
  (add-hook 'smie-indent-functions #'octave-indent-comment nil t)

  (setq-local smie-blink-matching-triggers
              (cons ?\; smie-blink-matching-triggers))
  (unless octave-blink-matching-block
    (remove-hook 'post-self-insert-hook #'smie-blink-matching-open 'local))

  (setq-local electric-indent-chars
              (cons ?\; electric-indent-chars))
  ;; IIUC matlab-mode takes the opposite approach: it makes RET insert
  ;; a ";" at those places where it's correct (i.e. outside of parens).
  (setq-local electric-layout-rules '((?\; . after)))

  (setq-local comment-use-syntax t)
  (setq-local comment-start octave-comment-start)
  (setq-local comment-end "")
  (setq-local comment-start-skip octave-comment-start-skip)
  (setq-local comment-add 1)

  (setq-local parse-sexp-ignore-comments t)
  (setq-local paragraph-start (concat "\\s-*$\\|" page-delimiter))
  (setq-local paragraph-separate paragraph-start)
  (setq-local paragraph-ignore-fill-prefix t)
  (setq-local fill-paragraph-function 'octave-fill-paragraph)

  (setq-local fill-nobreak-predicate
              (lambda () (eq (octave-in-string-p) ?')))
  (add-function :around (local 'comment-line-break-function)
                #'octave--indent-new-comment-line)

  (setq font-lock-defaults '(octave-font-lock-keywords))

  (setq-local syntax-propertize-function #'octave-syntax-propertize-function)

  (setq-local imenu-generic-expression octave-mode-imenu-generic-expression)
  (setq-local imenu-case-fold-search nil)

  (setq-local add-log-current-defun-function #'octave-add-log-current-defun)

  (add-hook 'completion-at-point-functions 'octave-completion-at-point nil t)
  (add-hook 'before-save-hook 'octave-sync-function-file-names nil t)
  (setq-local beginning-of-defun-function 'octave-beginning-of-defun)
  (and octave-font-lock-texinfo-comment (octave-font-lock-texinfo-comment))
  (add-hook 'eldoc-documentation-functions 'octave-eldoc-function nil t))