Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utop in emacs #12

Closed
monadbobo opened this issue Apr 24, 2013 · 6 comments
Closed

utop in emacs #12

monadbobo opened this issue Apr 24, 2013 · 6 comments

Comments

@monadbobo
Copy link

My os is MAC 10.7.5 and emacs version is 24.3.

I add follow line to my emacs config(.emacs):

(load-file "~/.opam/system/share/emacs/site-lisp/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)
(add-hook 'typerex-mode-hook 'utop-setup-ocaml-buffer)

and run utop in emacs , and then output

Process utop exited with code 2

but i run utop in my terminal , everything is ok.

Thanks.

@ghost
Copy link

ghost commented Apr 24, 2013

Can you check that ~/.opam/system/bin is in the PATH of your emacs process?

You can use the getenv function of emacs. For example press M-: then type:

(insert (replace-regexp-in-string ":" "\n" (getenv "PATH")))

If it is not this means that the environment variables of your emacs are not set correctly in order to use opam. Here is some emacs lisp code that should work, you can put it in your ~/.emacs:

(mapc
 (lambda (line)
   (when (string-match "\\(.*\\)=\\(.*\\)" line)
     (setenv (match-string 1 line) (match-string 2 line))))
 (split-string
  (shell-command-to-string "opam config -env")
  ";[ \r\n\t]*"))

@monadbobo
Copy link
Author

Thanks, everything is ok now.

@manzyuk
Copy link

manzyuk commented Jun 29, 2013

The documentation suggests setting utop-command to opam config exec "utop -emacs" if utop has been installed through opam. This solves the problem described here for me.

@Blaisorblade
Copy link

I needed to use (setq utop-command "opam config exec -- utop -emacs"). (EDITED).

First I tried (setq utop-command "opam config exec \"utop -emacs\""), but that didn't work (plus, opam config --help documents the latter syntax, not the former).

@Blaisorblade
Copy link

More importantly: I don't see documentation with this suggestion. Could this be added to the https://github.com/diml/utop/blob/master/README.md?

@ghost
Copy link

ghost commented Feb 9, 2016

Sure, I updated the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants