There is no need anymore to add the following line to your .emacs:
(autoload 'octave-mode "octave-mod" nil t)
Here is my init.el part for Xemacs for WIN32:
It is not yet working properly, but I hope others can help:
;;;;; ------ Octave-mode --------------------------------------------- ;; a tip from Jason Mobarak, http://cs.unm.edu/~jmob/windows-octave.txt ;; I don't know the reason (setenv "DISPLAY" "127.0.0.1:0.0")
;; autolad octave mode for *.m-files (autoload 'octave-mode "octave-mod" nil t) (setq auto-mode-alist (cons '("\\.m$" . octave-mode) auto-mode-alist))
;; to turn on the abbrevs, auto-fill and font-lock features automatically (add-hook 'octave-mode-hook (lambda () (abbrev-mode 1) (auto-fill-mode 1) (if (eq window-system 'x) (font-lock-mode 1))))
;; And finally, 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 () (turn-on-font-lock) (define-key inferior-octave-mode-map [up] 'comint-previous-input) (define-key inferior-octave-mode-map [down] 'comint-next-input)))
;; RET adds a newline and indents it (add-hook 'octave-mode-hook '(lambda nil (define-key octave-mode-map "\C-m" 'octave-reindent-then-newline-and-indent) (define-key octave-mode-map [(control space)] 'octave-complete-symbol) ;; I prefere C-SPC (define-key octave-mode-map [(meta control tab)] 'octave-complete-symbol)))
;; run an inferior Octave process in a special Emacs buffer (autoload 'run-octave "octave-inf" nil t)
;; if you have the win32 version of octave (add-hook 'inferior-octave-mode-hook '(lambda () (setq inferior-octave-program "C:\\Programme\\GNU Octave 2.1.73\\bin\\octave-2.1.73.exe")))
;; If `gnuserv' is installed, add the lines (autoload 'octave-help "octave-hlp" nil t) (require 'gnuserv) (gnuserv-start)
Known problems under WIN32:
Key stroke “M-TAB” (octave-complete-symbol) is not working, that is the reason for defining the keystroke [(meta control tab)].
Starting octave from within xemacs is not working 😟 Is there someone who can help?
You may consider convenience settings from the previous section. The only requirement however is to have
Not so long time ago mingw32 build of Octave began to use an experimental OpenGL as a default
graphics_toolkit (the case as of 2012-05-24). This effectively breaks lots of stuff including org-babel for octave. For off-screen plotting and subsequent printing into a file, one needs to override defaults with something like
This should make org-babel usable again with octave.
If you run inferior-octave and emacs becomes frozen, consider setting the same prompts for both octave and inferior octave:
Add PS1(">> ") to ~/.octaverc Add (setq inferior-octave-prompt ">> ") to ~/.emacs
As of 2018-04-22, the Octave was updated to 4.2.2 version, and using Inferior Octave under Win32 has some changes.
In brief, you should (1) ensure octave bin comes first in PATH. For example
(setenv "PATH" (concat "C:\\octave\\bin;" (getenv "PATH")))
and (2) set
inferior-octave-program point to “octave-gui.exe”. For example
(setq inferior-octave-program "C:/octave/bin/octave-gui.exe")
A recent version of Emacs (e.g. Emacs 25 and above) is also needed.
Note that in recent versions of Octave, after the above configuration, the plot commands don’t work properly. All the plot commands simply return and no figures are drawn. A workaround is run
close all before you plot.
Yasuto.Takenaka says: About octave-complete-symbol, add octave-completion-alist of auto-complete-octave.el of the wiki to octave-completion-alist:
(require 'octave-mod) (load-file "/path/auto-complete-octave.el") (setq octave-completion-alist (nconc octave-keywords octave-completion-alist)) ;If you don't use auto-complete.el, comment out lines of auto-complete.el concerned with "(require …, (defvar…, (add-hook…,(provide… ".
Octave has good completion support of its own. This code takes advantage of it in Emacs:
(defun my-inferior-octave-listening-p () "True if inferior octave is running and ready to receive input. Required for eldoc and other functions that try to get information from the running Octave, so they don't freeze emacs when Octave is busy doing something else." (and (boundp 'inferior-octave-process) inferior-octave-process (not inferior-octave-receive-in-progress) (eq (process-status inferior-octave-process) 'run))) (defun my-octave-complete-symbol () "Perform completion on Octave symbol preceding point. Compare that symbol against Octave's reserved words and builtin variables. This is like the default Octave completer function, except that it also completes on structure fields." (interactive) ;; This code taken from lisp-complete-symbol (let* ((end (point)) (beg (save-excursion (backward-sexp 1) (point))) (string (buffer-substring-no-properties beg end)) (completion (try-completion string octave-completion-alist))) (if completion (setq completion-list octave-completion-alist) (when (my-inferior-octave-listening-p) (setq completion-list (save-excursion (inferior-octave-send-list-and-digest (list (format "completion_matches(\"%s\");\n" string))) inferior-octave-output-list)) (when completion-list (setq completion (try-completion string inferior-octave-output-list))))) (cond ((eq completion t)) ; ??? ((null completion) (message "Can't find completion for \"%s\"" string)) ((not (string= string completion)) (delete-region beg end) (goto-char beg) (insert completion)) (t (let ((list (all-completions string completion-list)) (conf (current-window-configuration))) ;; Taken from comint.el (message "Making completion list...") (with-output-to-temp-buffer "*Completions*" (display-completion-list list)) (message "Hit space to flush") (let (key first) (if (save-excursion (set-buffer (get-buffer "*Completions*")) (setq key (read-key-sequence nil) first (aref key 0)) (and (consp first) (consp (event-start first)) (eq (window-buffer (posn-window (event-start first))) (get-buffer "*Completions*")) (eq (key-binding key) 'mouse-choose-completion))) (progn (mouse-choose-completion first) (set-window-configuration conf)) (if (eq first ?\ ) (set-window-configuration conf) (setq unread-command-events (listify-key-sequence key))))))))))
This is great. But for me the completion buffer doesn’t disappear when I make a choice or hit tab (sometimes it does when I hit space). Is there a way to make it disappear after typing the next character? – WCBeard