Hi all, I am pleased to announce the first release of Gopcaml-mode, a new emacs library that aims to extend the existing OCaml editing experience with structural editing capabilities.
A picture is worth a thousand words, so I’ll cut to the chase, and start with a few demonstrations:
- AST-based code navigation -
C-M-n, C-M-p, C-M-u, C-M-d, C-M-f, C-M-b
- AST-based code transformation -
C-M-N, C-M-P, C-M-F, C-M-B
- Mark exp -
- Extract expression into letdef -
This is just a small sample of the features - a full listing is provided at the project readme, which can be found at the project page.
This plugin is quite faithful to the OCaml specification and doesn’t reimplement a separate OCaml parser as some other plugins do - instead I use the Ecaml package (which allows interfacing with Emacs from OCaml code) to allow delegating to the OCaml parser (from Ocaml-compiler-libs) directly.
It’s in the process of being published to opam, and should be available to download soon.
Edit: It has now been merged into the opam-repositories and can be installed via opam:
- Install the package from opam
opam install gopcaml-mode
- load the package in your init.el
(let ((opam-share (ignore-errors (car (process-lines "opam" "config" "var" "share"))))) (when (and opam-share (file-directory-p opam-share)) ;; Register Gopcaml mode (add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share)) (autoload 'gopcaml-mode "gopcaml-mode" nil t nil) ;; Automatically start it in OCaml buffers (setq auto-mode-alist (append '(("\\.ml[ily]?$" . gopcaml-mode) ("\\.topml$" . gopcaml-mode)) auto-mode-alist)) ))
- (Optional) install
multiple-cursorsto enable extraction and
smartparensfor better handling of parenthesis.