Run Octave from Emacs on iMac

元气小坏坏 提交于 2020-01-06 14:21:56

问题


Octave is installed on my iMac in /applications and works properly.
Emacs is installed on my iMac in /applications and file editing is possible.
Now I want to run Octave from Emacs. M-xrun-octave results in:

Searching for program: No such file or directory, octave

In Windows I solved this problem by adding Octave to the environment path, how can I do this on a Mac?

Thank in advance, Hans Sellmeijer


回答1:


Here are two possible solutions:

  1. Find the actual Octave executable by typing which octave in your shell. E.g., if installed via Macports it's at /opt/local/bin/octave. Then, in Emacs, do M-x customize-group RET octave-inferior RET, edit the value of Inferior Octave Program to this value and click State > Save for Future Sessions.

    Alternatively, you can do this in Elisp by putting the following in your .emacs or init.el file (obviously changing the quoted part as necessary):

    (setq inferior-octave-program "/opt/local/bin/octave")

  2. You can add octave to the PATH environment variable just as on Windows, but Emacs started from the Finder under Mac OS X doesn't get any environment settings that you might have put in .bashrc or similar. Either run Emacs from a terminal window, or put in your .emacs:

    (add-to-list 'exec-path "/opt/local/bin")

Hope that helps.




回答2:


Thanks to Jon, Emacs handles Octave properly on iMac with Snow-Leopard. The ".emacs" file contains:

(add-to-list 'exec-path "/applications/Octave.app/Contents/Resources/bin")
(autoload 'octave-mode "octave-mod" nil t)
(setq auto-mode-alist (cons '("\\.m$" . octave-mode) auto-mode-alist))
(add-hook 'octave-mode-hook (lambda () (abbrev-mode 1) (auto-fill-mode 1) (if (eq window-system 'x) (font-lock-mode 1))))
(autoload 'run-octave "octave-inf" nil t)

Be careful with copying these lines from a .PDF manual. The quote is deformed to escape sequences, which cripples proper use.




回答3:


This is how I was able to get Octave (including plots) running in Emacs on my Mac (OS X 10.7.3):

  1. Install octave from source: fink install octave. This also installed all the dependencies for gnuplot, which the binary distribution does not seem to do correctly (at least, it didn't work for me). Only downside is that the install took several hours to complete on my MacBook Air.
  2. Customize octave-inferior in .emacs: (you may have more variables in this list):
    (custom-set-variables
    '(inferior-octave-program "/sw/bin/octave")
    '(inferior-octave-startup-args (quote ("-i")))


来源:https://stackoverflow.com/questions/8247072/run-octave-from-emacs-on-imac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!