Emacs 24 和 Mac OSX Mavericks,我的 emacs 文件如下:
(setq debug-on-error t)
;; -- common-lisp compatibility if not added earlier in your .emacs
(require 'cl)
;; -- Tuareg mode -----------------------------------------
;; Add Tuareg to your search path
(add-to-list
'load-path
;; Change the path below to be wherever you've put your tuareg installation.
(expand-file-name "~/.elisp/tuareg"))
(require 'tuareg)
(setq auto-mode-alist
(append '(("\\.ml[ily]?$" . tuareg-mode))
auto-mode-alist))
;; -- Tweaks for OS X -------------------------------------
;; Tweak for problem on OS X where Emacs.app doesn't run the right
;; init scripts when invoking a sub-shell
(cond
((eq window-system 'ns) ; macosx
;; Invoke login shells, so that .profile or .bash_profile is read
(setq shell-command-switch "-lc")))
;; -- opam and utop setup --------------------------------
;; Setup environment variables using opam
(defun opam-vars ()
(let* ((x (shell-command-to-string "opam config env"))
(x (split-string x "\n"))
(x (remove-if (lambda (x) (equal x "")) x))
(x (mapcar (lambda (x) (split-string x ";")) x))
(x (mapcar (lambda (x) (car x)) x))
(x (mapcar (lambda (x) (split-string x "=")) x))
)
x))
(dolist (var (opam-vars))
(setenv (car var) (substring (cadr var) 1 -1)))
;; The following simpler alternative works as of opam 1.1
;; (dolist
;; (var (car (read-from-string
;; (shell-command-to-string "opam config env --sexp"))))
;; (setenv (car var) (cadr var)))
;; Update the emacs path
(setq exec-path (split-string (getenv "PATH") path-separator))
;; Update the emacs load path
(push (concat (getenv "OCAML_TOPLEVEL_PATH")
"/../../share/emacs/site-lisp") load-path)
;; Automatically load utop.el
(autoload 'utop "utop" "Toplevel for OCaml" t)
(autoload 'utop-setup-ocaml-buffer "utop" "Toplevel for OCaml" t)
(add-hook 'tuareg-mode-hook 'utop-setup-ocaml-buffer)
解决此错误的任何帮助都会很棒。谢谢!
Nots:我确实有 tuareg 模式,我说的是(in~/.elisp/tuareg)。执行以下操作后,我开始收到此错误:
opam install \
async yojson core_extended core_bench \
cohttp async_graphics cryptokit menhir
不知道出了什么问题,但在安装这些之前我有基本相同的 emacs 文件并且没有问题。现在在 emacs 中,当我尝试评估 ocaml 文件时,utop 也无法正常运行。