emacs 0.4.0

Rust library for creating emacs modules
Documentation

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:
    [lib]
    crate-type = ["cdylib"]
    
    [dependencies]
    emacs = "0.4.0"
    
  • Write some code in your src/lib.rs following this skeleton.
    #[macro_use]
    extern crate emacs;
    
    use emacs::{Env, Result, Value};
    
    emacs_plugin_is_GPL_compatible!();
    emacs_module_init!(init);
    
    pub fn init(env: &Env) -> Result<Value> {
       // Initialization code
    
       env.provide("my-module")
    }
    
  • 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.

Development

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