Writing Emacs plugin in OCaml
OCaml C Makefile
Latest commit f59c0c7 Feb 27, 2017 @diml diml 114.33+30
Failed to load latest commit information.
example 114.33+30 Feb 27, 2017
src 114.33+30 Feb 27, 2017
test 114.33+30 Feb 27, 2017
.gitignore 114.20+69 Dec 15, 2016
LICENSE.txt 114.08+09 Aug 29, 2016
Makefile 114.33+30 Feb 27, 2017
README.md 114.10+84 Sep 16, 2016
ecaml.opam 114.33+30 Feb 27, 2017


Emacs plugin in OCaml

Ecaml is a library for writing Emacs plugins in OCaml. It uses Emacs 25 support for plugins to load native OCaml code into Emacs.

Building a plugin

Using Jane Street jenga rules

Simply add (only_shared_object true) to the executables stanza in your jbuild. For instance:

 ((names (my_plugin))
  (libraries (ecaml))
  (only_shared_object true)))

Then build my_plugin.so with jenga. This has been tested in opam using jane-build.

Using other build systems

You need to use the -output-complete-obj option of ocamlopt to produce a self-contained shared object file. For instance to build the plugin in the example/ directory:

$ ocamlfind ocamlopt -linkpkg -package ecaml -thread -output-complete-obj \
    -runtime-variant _pic -pp ppx-jane example_plugin.ml -o example_plugin.so


As of Emacs version 25, Emacs supports plugins. Here is the API:


Here's a tutorial:


Here's an example plugin:



Note that Emacs modules must be GPL compatible, so you must make sure that your work based on Ecaml is released under a GPL compatible license.

Ecaml itself is released under the Apache 2.0 license which is GPL compatible.