我在 mac os x 10.9 上运行 emacs 24.3。我已经安装了用于 ocaml 编程的 tuareg-mode,但无法使用命令 C-c C-b 进行编译。按下相同按钮后,迷你缓冲区会询问我“要运行的 Caml 顶层:ocaml”。当我按 Enter 时,它显示错误“搜索程序:没有这样的文件或目录,ocaml”。我错过了什么?
最佳答案
您需要将 PATH
环境变量和 Emacs 的 exec-path
变量设置为正确的值。一种可能性是使用类似的东西(在您的 ~/.emacs
中):
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell (shell-command-to-string "$SHELL -c 'echo $PATH'")))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(when window-system (set-exec-path-from-shell-PATH))
从 shell 正确获取 PATH
和两个变量。这样做的一个优点是您只需在一处设置 PATH
- 在 shell 初始化脚本中。
关于macos - tuareg 模式 emacs ocaml 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20801675/