Dynamic modules in Emacs
This repo contains examples of creating dynamic modules for Emacs.
Contents
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
Miscellaneous
- ./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
testing modules
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-linalgOr 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
- joymacs
- http://nullprogram.com/blog/2016/11/05/
- mruby
- https://github.com/syohex/emacs-mruby-test
- https://github.com/tromey/emacs-ffi
- an actual ffi for emacs
- elfuse
- https://github.com/vkazanov/elfuse a file system in Emacs
- asynchronous events
- http://nullprogram.com/blog/2017/02/14/ related to elfuse
- emacs-sqlite3
- sqlite3 binding of Emacs Lisp
- emacs-parson
- JSON parser with dynamic module feature with parson
- libyaml
- libyaml
- emacs-perl
- Embed Perl into Emacs
- https://github.com/syohex/emacs-eject
- eject a cd
- emacs-capstone
- elisp bindings for the capstone disassembler
- emacs-csound
- EmacsLisp link to Csound’s API via Emacs Modules
- emacs-cmigemo
- Emacs dynamic module for cmigemo
- emacs-cipher
- OpenSSL cipher binding of Emacs Lisp
- emacs-lua
- Lua engine from Emacs Lisp
- emacs-ztd
- libzstd binding of Emacs Lisp
- mem-cached
- libmemcached
- https://coldnew.github.io/2d16cc25/
- 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
- golang
- 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