在 iMac 上从 Emacs 运行 Octave

发布于 2024-12-17 11:17:21 字数 359 浏览 3 评论 0原文

Octave 安装在我的 iMac 上的 /applications 中并正常工作。
Emacs 安装在我的 iMac 上的 /applications 中,并且可以编辑文件。
现在我想从 Emacs 运行 Octave。 Mxrun-octave 结果:

Searching for program: No such file or directory, octave

在 Windows 中,我通过将 Octave 添加到环境路径解决了这个问题,如何在 Mac 上执行此操作?

预先感谢汉斯·塞尔梅杰

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

野稚 2024-12-24 11:17:21

以下是两种可能的解决方案:

  1. 通过在 shell 中输入 which Octave 查找实际的 Octave 可执行文件。例如,如果通过 Macports 安装,则位于 /opt/local/bin/octave。然后,在 Emacs 中,执行 Mxcustomize-group RET Octave-inferior RET,将 Inferior Octave Program 的值编辑为此值,然后单击 State > 。保存以供将来使用

    或者,您可以在 Elisp 中执行此操作,方法是将以下内容放入 .emacsinit.el 文件中(显然,根据需要更改引用的部分):

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

  2. 你可以像在 Windows 上一样将 Octave 添加到 PATH 环境变量中,但在 Mac OS X 下从 Finder 启动的 Emacs 则不能获取任何环境设置您可能已经输入了 .bashrc 或类似内容。从终端窗口运行 Emacs,或者放入 .emacs:

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

希望有所帮助。

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.

我恋#小黄人 2024-12-24 11:17:21

感谢 Jon,Emacs 可以在带有 Snow-Leopard 的 iMac 上正确处理 Octave。 “.emacs”文件包含:

(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)

从 .PDF 手册复制这些行时要小心。引用被变形为转义序列,这削弱了正确的使用。

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.

蓝眸 2024-12-24 11:17:21

这就是我如何在 Mac (OS X 10.7.3) 上的 Emacs 中运行 Octave(包括绘图):

  1. 从源代码安装 Octave:fink install Octave。这还安装了 gnuplot 的所有依赖项,二进制发行版似乎没有正确执行该操作(至少,它对我不起作用)。唯一的缺点是在我的 MacBook Air 上安装需要几个小时才能完成。
  2. .emacs 中自定义 octave-inferior:(此列表中可能有更多变量):
    (custom-set-variables
    '(inferior-octave-program "/sw/bin/octave")
    '(inferior-octave-startup-args (quote ("-i")))

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")))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文