Skip to main content

emacs/
lib.rs

1//! This provides a high-level binding to `emacs-module`, Emacs's support for dynamic modules.
2//!
3//! Code for a minimal module looks like this:
4//!
5//! ```
6//! use emacs::{defun, Env, Result, Value};
7//!
8//! emacs::plugin_is_GPL_compatible!();
9//!
10//! #[emacs::module(name = "greeting")]
11//! fn init(_: &Env) -> Result<()> { Ok(()) }
12//!
13//! #[defun]
14//! fn say_hello(env: &Env, name: String) -> Result<Value<'_>> {
15//!     env.message(&format!("Hello, {}!", name))
16//! }
17//! ```
18//!
19//! ```emacs-lisp
20//! (require 'greeting)
21//! (greeting-say-hello "Emacs")
22//! ```
23//!
24//! See [User Guide] and [examples].
25//!
26//! [User Guide]: https://ubolonton.github.io/emacs-module-rs/
27//! [Examples]: https://github.com/ubolonton/emacs-rs-examples/
28
29#![allow(mismatched_lifetime_syntaxes)]
30
31#[doc(inline)]
32pub use emacs_macros::{defun, module};
33
34#[doc(inline)]
35pub use self::{
36    env::Env,
37    value::Value,
38    global::{GlobalRef, OnceGlobalRef},
39    types::{FromLisp, IntoLisp, Transfer, Vector},
40    func::CallEnv,
41    error::{ErrorKind, Result, ResultExt, Error},
42};
43
44#[macro_use] mod macros;
45
46#[doc(hidden)]
47pub mod init;
48#[doc(hidden)]
49pub mod func;
50
51mod env;
52mod value;
53mod types;
54mod error;
55mod call;
56#[macro_use]
57mod global;
58mod symbol;
59mod subr;
60
61/// This exposes some raw types for module to use (e.g. in `emacs_module_init`) without having to
62/// declare the raw `emacs_module` as a dependency.
63#[doc(hidden)]
64pub mod raw {
65    pub use emacs_module::{emacs_runtime, emacs_env, emacs_value};
66}
67
68/// External dependencies that are mostly used by macros instead of user code.
69#[doc(hidden)]
70pub mod deps {
71    pub use emacs_macros;
72    pub use ctor;
73}