首页 > AI前沿 > Rune: Rust VM for Emacs

Rune: Rust VM for Emacs

Hacker News 2026-11-24 10:30 5 阅读 查看原文
Rune R ust UN der E macs video introduction Docs This project is an experimental Emacs core written in Rust. The project is still at a very early phase but has the following goals: Bring multi-threaded elisp to Emacs Be “bug-compatible” with existing Emacs Lisp packages (everything should still work) Enable performance improvements (including faster GC, regex, and JSON) by leveraging the Rust Ecosystem. See the design doc for more details. Status The current goal of this project is to create an editor MVP. We have a basic elisp runtime, and we are working on adding basic editing functionality in a minimal GUI. This will include: buffer text insertion/deletion cursor line wrapping scrolling file IO display tables If you want to contribute or have ideas for things to add, please open an issue. lisp Lisp files are currently pulled from https://github.com/emacs-mirror/emacs/tree/emacs-29.1/lisp Any modification for bootstrapping contain the tag RUNE-BOOTSTRAP. Running MIRI Run the test suite with MIRI MIRIFLAGS='-Zmiri-strict-provenance' cargo +nightly miri test Exploring this repo The project is defined by a main package rune, which depends on the crates included in the crates directory. One of those is the rune-macros crate, which defines the defun proc macro for defining builtin functions. The rest of the code is contained in src/. The modules are described below. Contributing See the architecture doc for more info on the structure of Rust Emacs internals. This project is moved forward by trying to load new elisp files and seeing what breaks. The best way to do that is with cargo run, which will load the currently bootstrapped files. The bootstrapped files are located in main.rs as part of the load function. Usually what is needed is to implement more primitive functions. This is done with the defun macro. For example, if we wanted to implement the substring function, we would first look at the lisp signature. (substring STRING &optional FROM TO) Then we would translate the types to their Rust equivalent. If the correct type is not known we can use Object. In this example we would write our Rust signature as follows: #[defun] fn substring(string: &str, from: Option , to: Option ) -> String {...} To load a new elisp file, run cargo run --release -- --load . Files that are not bootstrapped are not yet included in this repo, but are part of Emacs. Once the file is bootstrapped it can be added to the lisp directory. Property testing Rune includes the `assert_elprop!` macro, which enables property testing against GNU Emacs. This macro works by sending the same Lisp form to both Rune and Emacs and then comparing their results. It can also be used in conjunction with the `proptest` crate. Examples: #[test] fn test_addition() { // Verify that (+ 40 2) evaluates to 42 for both Rune and Emacs assert_elprop!["(+ 40 2)"]; } // Verify that make-vector works for any arbitrary byte proptest! { #[test] fn test_make_vector_consistency(size in arb_byte()) { assert_elprop!["(make-vector {} ?A)", size]; } } How to run Windows tests on Linux with Wine Define WINEPREFIX: export WINEPREFIX=$PWD/.wine Add x86_64-pc-windows-gnu to rust toolchain: rustup target add x86_64-pc-windows-gnu Setup the wineprefix: `./scripts/setup-wineprefix`. This script will install Emacs inside the prefix as well Now you can run the tests on Windows like that: cargo test --target x86_64-pc-windows-gnu. In case you use Nix enviroment you should skip 1 and 2 points. Also, you can tell eglot to check the code marked with #[cfg(windows)]. Just add the following to .dir-locals.el and restart eglot: ((nil . ((eglot-workspace-configuration . (:rust-analyzer (:cargo (:target "x86_64-pc-windows-gnu"))))))) Blog posts A vision of a multi-threaded Emacs :: Some ideas about how to add multi-threading to the existing language. Further exploration