Skip to content

Commit 4a2b0be

Browse files
committed
[emacs] sort out ocaml mode: tuareg, ocp-indent, merlin
1 parent 14188ad commit 4a2b0be

File tree

1 file changed

+35
-63
lines changed

1 file changed

+35
-63
lines changed

emacs

+35-63
Original file line numberDiff line numberDiff line change
@@ -428,69 +428,41 @@ started from a shell."
428428
;; '(lambda ()
429429
;; ))
430430

431-
;; tuareg-mode
432-
;; (add-hook 'tuareg-mode-hook
433-
;; '(lambda ()
434-
;; (fci-mode 1)
435-
;; (setq tuareg-lazy-= t) ; indent `=' like a standard keyword
436-
;; (setq tuareg-lazy-paren t) ; indent [({ like standard keywords
437-
;; (setq tuareg-in-indent 0) ; no indentation after `in' keywords
438-
;; (auto-fill-mode 1) ; turn on auto-fill minor mode
439-
;; ;; (setq tuareg-default-indent 2)
440-
;; ;; (if (featurep 'sym-lock) ; Sym-Lock customization only
441-
;; ;; (setq sym-lock-mouse-face-enabled nil))
442-
;; ;; ; turn off special face under mouse
443-
;; ;; (set-face-background caml-types-expr-face "slategray")
444-
;; ))
445-
446-
;; typerex-mode (ocaml)
447-
;; (add-hook 'typerex-mode-hook
448-
;; (lambda ()
449-
;; ))
450-
(autoload 'typerex-mode "typerex.el" "Major mode for editing Caml code" t)
451-
(push'("\\.ml[iylp]?" . typerex-mode) auto-mode-alist)
452-
(push '("\\.fs[ix]?" . typerex-mode) auto-mode-alist)
453-
454-
;; TypeRex mode configuration
455-
(setq ocp-server-command "/usr/local/bin/ocp-wizard")
456-
(setq typerex-in-indent 0)
457-
(setq-default indent-tabs-mode nil)
458-
459-
;; Uncomment to enable typerex command menu by right click
460-
(setq ocp-menu-trigger [mouse-3])
461-
462-
;; Uncomment make new syntax coloring look almost like Tuareg
463-
(setq ocp-theme "tuareg_like")
464-
;; Uncomment to disable new syntax coloring and use Tuareg
465-
;(setq ocp-syntax-coloring nil)
466-
467-
;;;; Auto completion (experimental)
468-
;;;; Don't use M-x invert-face default with auto-complete! (emacs -r is OK)
469-
;;(add-to-list 'load-path "/Users/mort/.emacs.d/auto-complete-mode")
470-
;;(setq ocp-auto-complete t)
471-
472-
;;;; Using <`> to complete whatever the context, and <C-`> for `
473-
;;(setq auto-complete-keys 'ac-keys-backquote-backslash)
474-
;;;; Options: nil (default), 'ac-keys-default-start-with-c-tab, 'ac-keys-two-dollar
475-
;;;; Note: this overrides individual auto-complete key settings
476-
477-
;;;; I want immediate menu pop-up
478-
;;(setq ac-auto-show-menu 0.1)
479-
;;;; Short delay before showing help
480-
;;(setq ac-quick-help-delay 0.3)
481-
;;;; Number of characters required to start (nil to disable)
482-
;;(setq ac-auto-start 0)
483-
484-
;;;; Uncomment to enable auto complete mode globally (independently of OCaml)
485-
;;(require 'auto-complete-config)
486-
;;(add-to-list 'ac-dictionary-directories "/Users/mort/.emacs.d/auto-complete-mode/ac-dict")
487-
;;(ac-config-default)
488-
;;(global-set-key (kbd "C-<tab>") 'auto-complete)
489-
490-
;; For debugging only
491-
;;;;(setq ocp-debug t)
492-
;;;;(setq ocp-profile t)
493-
;;;;(setq ocp-dont-catch-errors t)
431+
;; ocaml
432+
433+
;; ocp-indent
434+
(load-file (concat
435+
(substring (shell-command-to-string "opam config var prefix") 0 -1)
436+
"/share/typerex/ocp-indent/ocp-indent.el"
437+
))
438+
439+
;; merlin-mode
440+
(push (concat
441+
(substring (shell-command-to-string "opam config var share") 0 -1)
442+
"/emacs/site-lisp"
443+
)
444+
load-path)
445+
446+
(setq merlin-command
447+
(concat
448+
(substring (shell-command-to-string "opam config var bin") 0 -1)
449+
"/ocamlmerlin"
450+
))
451+
(autoload 'merlin-mode "merlin" "Merlin mode" t)
452+
453+
(add-hook 'tuareg-mode-hook
454+
'(lambda ()
455+
(merlin-mode)
456+
(setq indent-line-function 'ocp-indent-line)
457+
(setq merlin-use-auto-complete-mode t)
458+
;; (setq tuareg-lazy-= t) ; indent `=' like a standard keyword
459+
;; (setq tuareg-lazy-paren t) ; indent [({ like standard keywords
460+
;; (setq tuareg-in-indent 0) ; no indentation after `in' keywords
461+
(local-set-key (kbd "C-S-<up>") 'merlin-type-enclosing-go-up)
462+
(local-set-key (kbd "C-S-<down>") 'merlin-type-enclosing-go-down)
463+
))
464+
(push'("\\.ml[iylp]?" . tuareg-mode) auto-mode-alist)
465+
(push '("\\.fs[ix]?" . tuareg-mode) auto-mode-alist)
494466

495467
;; org-mode: Holidays -- from <http://www.gnomon.org.uk/diary.html>
496468

0 commit comments

Comments
 (0)