Emacs Module in Rust
emacs-module-rs
provides high-level Rust binding for Emacs's dynamic module support, and tools that make writing modules easier. It currently supports stable Rust, Emacs 25, OS X and Ubuntu.
Writing a Module
- Modify your
Cargo.toml
:[] = ["cdylib"] [] = "0.4.0"
- Write some code in your
src/lib.rs
following this skeleton.extern crate emacs; use ; emacs_plugin_is_GPL_compatible!; emacs_module_init!;
- Build the code with
cargo build
- Create a symlink with
.so
extensioncd target/debug ln -s libmy_module.dylib my-module.so
- Add
target/debug
to your Emacs'sload-path
. - Load it in Emacs
(require 'my-module)
Live Reloading
Emacs does not support unloading modules. Live reloading thus requires a custom module loader. rs-module is one such loader (which itself is a module that must be loaded by Emacs's normal loading mechanism). See load.sh.
Sample Modules
test-module uses most of the provided features.
Development
- Building:
cargo build --all
- Testing:
bin/test.sh
- Continuous testing (requires
cargo-watch
):cargo watch -x 'build --all' -s bin/test.sh