Dynamic modules in Emacs
This repo contains examples of creating dynamic modules for Emacs.
This repo mostly contains proofs of concept so many of these may contain only a single or small number of functions.
- ./examples.org has examples of using these libraries. Usually these have been blogged at some point.
The GNU Scientific library
- ./gsl-constants.c shows how to expose constants to Emacs
- ./gsl-linalg.c shows how to deal with arrays and return a vector.
- ./gsl-integration.c shows how to integrate a function. It is a little improved over the blogpost.
- ./gsl-roots.c is similar to the integration library but implements a root finder
- ./mod-types.c shows how to test the type of an arg, and how to get a function to work for integers and floats. Also this has a little variadic function definition.
- ./mod-list-vec.c contains some test functions for making vectors and indexing them.
- ./emacs-module-helpers.c provides convenience functions like provide and DEFUN.
Notes to me
It is moderately tedious to test modules because once you load them you cannot rebuild and reload them. You have to kill emacs and try again. Here is a pretty fast way to test modules. You develop in one emacs, and run the appropriate make command to build it.
Add test functions to ./tests.el. Then run them from the command line like this.
emacs -batch -q -l tests.el -f test-linalg
Or add lines like that one to the Makefile.
Resources on dynamic modules
For my own notes here are all the resources on dynamic modules I know of:
Here are the official Emacs header and example: emacs-module.h: http://git.savannah.gnu.org/cgit/emacs.git/tree/src/emacs-module.h?id=e18ee60b02d08b2f075903005798d3d6064dc013 mod_test.c: http://git.savannah.gnu.org/cgit/emacs.git/tree/modules/mod-test/mod-test.c?id=e18ee60b02d08b2f075903005798d3d6064dc013
This simple example in C http://diobla.info/blog-archive/modules-tut.html
- an actual ffi for emacs
- https://github.com/vkazanov/elfuse a file system in Emacs
- asynchronous events
- http://nullprogram.com/blog/2017/02/14/ related to elfuse
- sqlite3 binding of Emacs Lisp
- JSON parser with dynamic module feature with parson
- Embed Perl into Emacs
- eject a cd
- elisp bindings for the capstone disassembler
- EmacsLisp link to Csound’s API via Emacs Modules
- Emacs dynamic module for cmigemo
- OpenSSL cipher binding of Emacs Lisp
- Lua engine from Emacs Lisp
- libzstd binding of Emacs Lisp
- in Chinese, but with code
A collection of module resources: https://github.com/emacs-pe/emacs-modules
- Nim https://github.com/yuutayamada/nim-emacs-module
- OCaml https://github.com/janestreet/ecaml
- Rust https://github.com/lunaryorn/emacs-module.rs https://github.com/jjpe/emacs_module_bindings
- https://github.com/sigma/go-emacs writing modules in go
This may not be a dynamic module but claims an ffi haskell https://github.com/knupfer/haskell-emacs