Cygwin 中的 Opam 与 Windows emacs
Opam in Cygwin with Windows emacs
我在Cygwin中成功安装了https://github.com/fdopen/opam-repository-mingw、merlin和tuareg。现在我已经安装了 Windows emacs 并更改了 .emacs 以启用模式来编辑 Ocaml 文件。
设置应该是这样的吗? Windows emacs 可以像这样使用 Cygwin OCaml 工具吗?
如果没有,那么我要求提供在 Cygwin 中设置 emacs 的详细信息。
更新:现在我的init.el是这个
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(setenv "PATH" (concat "c:/OCaml64/bin;" (getenv "PATH")))
(setq exec-path (cons "c:/OCaml64/bin/" exec-path))
(require 'cygwin-mount)
(cygwin-mount-activate)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages (quote (company))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; OCaml code
(add-hook
'tuareg-mode-hook
(lambda ()
;; Add opam emacs directory to the load-path
(setq opam-share
(substring
(shell-command-to-string "opam config var share 2> /dev/null")
0 -1))
(add-to-list 'load-path (concat opam-share "/emacs/site-lisp"))
;; Load merlin-mode
(require 'merlin)
;; Start merlin on ocaml files
(add-hook 'tuareg-mode-hook 'merlin-mode t)
(add-hook 'caml-mode-hook 'merlin-mode t)
;; Enable auto-complete
(setq merlin-use-auto-complete-mode 'easy)
;; Use opam switch to lookup ocamlmerlin binary
(setq merlin-command 'opam)
(company-mode)
(require 'ocp-indent)
(autoload 'utop-minor-mode "utop" "Minor mode for utop" t)
(autoload 'utop-setup-ocaml-buffer "utop" "Toplevel for OCaml" t)
(autoload 'merlin-mode "merlin" "Merlin mode" t)
(utop-minor-mode)
(company-quickhelp-mode)
;; Important to note that setq-local is a macro and it needs to be
;; separate calls, not like setq
(setq-local merlin-completion-with-doc t)
(setq-local indent-tabs-mode nil)
(setq-local show-trailing-whitespace t)
(setq-local indent-line-function 'ocp-indent-line)
(setq-local indent-region-function 'ocp-indent-region)
(merlin-mode)))
(add-hook 'utop-mode-hook (lambda ()
(set-process-query-on-exit-flag
(Get-process "utop") nil)))
cygwin-mount.el 在 site-lisp 文件夹中。
打开 .ml 文件或键入 M-x merlin-mode 时我没有看到任何变化
您确定 Tuareg
确实已加载吗?如果你转到*scratch*
,键入(locate-library "tuareg")
并执行它(当光标在右大括号之后时键入C-xC-e
),你会在回显区域看到什么?
在你安装图阿雷格人的目录下,应该有一个文件tuareg-site-file.el
。如果是这样,请输入您的 ~/.emacs
,行:
(load "/path/to/tuareg-site-file")
启用图阿雷格语。
我在Cygwin中成功安装了https://github.com/fdopen/opam-repository-mingw、merlin和tuareg。现在我已经安装了 Windows emacs 并更改了 .emacs 以启用模式来编辑 Ocaml 文件。
设置应该是这样的吗? Windows emacs 可以像这样使用 Cygwin OCaml 工具吗?
如果没有,那么我要求提供在 Cygwin 中设置 emacs 的详细信息。
更新:现在我的init.el是这个
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(setenv "PATH" (concat "c:/OCaml64/bin;" (getenv "PATH")))
(setq exec-path (cons "c:/OCaml64/bin/" exec-path))
(require 'cygwin-mount)
(cygwin-mount-activate)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages (quote (company))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; OCaml code
(add-hook
'tuareg-mode-hook
(lambda ()
;; Add opam emacs directory to the load-path
(setq opam-share
(substring
(shell-command-to-string "opam config var share 2> /dev/null")
0 -1))
(add-to-list 'load-path (concat opam-share "/emacs/site-lisp"))
;; Load merlin-mode
(require 'merlin)
;; Start merlin on ocaml files
(add-hook 'tuareg-mode-hook 'merlin-mode t)
(add-hook 'caml-mode-hook 'merlin-mode t)
;; Enable auto-complete
(setq merlin-use-auto-complete-mode 'easy)
;; Use opam switch to lookup ocamlmerlin binary
(setq merlin-command 'opam)
(company-mode)
(require 'ocp-indent)
(autoload 'utop-minor-mode "utop" "Minor mode for utop" t)
(autoload 'utop-setup-ocaml-buffer "utop" "Toplevel for OCaml" t)
(autoload 'merlin-mode "merlin" "Merlin mode" t)
(utop-minor-mode)
(company-quickhelp-mode)
;; Important to note that setq-local is a macro and it needs to be
;; separate calls, not like setq
(setq-local merlin-completion-with-doc t)
(setq-local indent-tabs-mode nil)
(setq-local show-trailing-whitespace t)
(setq-local indent-line-function 'ocp-indent-line)
(setq-local indent-region-function 'ocp-indent-region)
(merlin-mode)))
(add-hook 'utop-mode-hook (lambda ()
(set-process-query-on-exit-flag
(Get-process "utop") nil)))
cygwin-mount.el 在 site-lisp 文件夹中。
打开 .ml 文件或键入 M-x merlin-mode 时我没有看到任何变化
您确定 Tuareg
确实已加载吗?如果你转到*scratch*
,键入(locate-library "tuareg")
并执行它(当光标在右大括号之后时键入C-xC-e
),你会在回显区域看到什么?
在你安装图阿雷格人的目录下,应该有一个文件tuareg-site-file.el
。如果是这样,请输入您的 ~/.emacs
,行:
(load "/path/to/tuareg-site-file")
启用图阿雷格语。