This crate provides access to the new Emacs module
functionality recently
introduced in Emacs 25. It's a basic FFI with a relatively straightforward
API. Have have a look at the source for details.
$EMB_PATH
lib
project, say my_fancy_module
Cargo.toml
in an editor, and:
crate-type = ["cdylib"]
to the [lib]
section (NOTE: Only
Rust nightly correctly handles this at the moment)toml
libc = "0.2.14"
emacs_module_bindings = { path = "$EMB_PATH" }
Add the following to your src/lib.rs
:
```` Rust
extern crate libc;
extern crate emacsmodulebindings as emacs;
use emacs::emacs_module::{EmacsEnv, EmacsRT, EmacsVal};
/// This states that the module is GPL-compliant. /// Emacs won't load the module if this symbol is undefined.
pub static pluginisGPLcompatible: libc::cint = 0;
pub extern "C" fn emacsmoduleinit(ert: *mut EmacsRT) -> libc::cint { let env = emacs::getenvironment(ert);
// Add any other things you need the module to do here
emacs::provide(env, "my-fancy-module"); 0 } ````
cargo build
target/debug/libmy_fancy_module.dylib
to target/debug/libmy_fancy_module.so
(require 'my-fancy-module "/path/to/libmy_fancy_module.so")
.
Note that this requires Emacs to be configured and compiled with
the --with-modules
flag.