emacs 0.4.0

Rust library for creating emacs modules

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:
    crate-type = ["cdylib"]
    emacs = "0.4.0"
  • Write some code in your src/lib.rs following this skeleton.
    extern crate emacs;
    use emacs::{Env, Result, Value};
    pub fn init(env: &Env) -> Result<Value> {
       // Initialization code
  • Build the code with cargo build
  • Create a symlink with .so extension
    cd target/debug
    ln -s libmy_module.dylib my-module.so
  • Add target/debug to your Emacs's load-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.


  • Building:
    cargo build --all
  • Testing:
  • Continuous testing (requires cargo-watch):
    cargo watch -x 'build --all' -s bin/test.sh