Parinfer is a plugin that aims to make writing lisp simple. This library wraps justinbarclay/parinfer-rust to provide an Emacs minor mode. parinfer-rust-mode aims to be a simpler adaptation of Parinfer that only offers “smart mode”, leveraging the parinfer-rust plugin to do most of the heavy lifting.
- Making code auto-adhere to formatting conventions
- Influencing expression-nesting with indentation
- Maintaining indentation when expressions shift
- Allowing Paredit-like features without hot keys
- Emacs (25+) compiled with Dynamic Module support.
- Running on MacOS/Linux, with Windows support coming soon.
- (Optional) Curl - to download the library for you
When compiling manually the library name differs from platform to platform. Additionally, Emacs expects that these libraries have specific file extensions when first loading them up. This is a problem for MacOS because Rust compiles it as .dylib
and we’ll need to give the file an .so
extension when we copy it to it’s final location.
Platform | File name | Required extension |
---|---|---|
Linux | libparinfer_rust.so | .so |
MacOS | libparinfer_rust.dylib | .so |
Windows | parinfer_rust.dll | .dll |
git clone https://github.com/eraserhd/parinfer-rust.git
cd parinfer-rust
cargo build --release
cp ./target/release/${library-name} ~/.emacs.d/parinfer-rust/${lib-name}
Once you have compiled the libraries from source code you’ll need to tell parinfer-rust-mode
how to find these libraries
(setq parinfer-rust-library "/path/to/parinfer-rust-library.so")
cd /path/for/elisp-packages
git clone [email protected]:justinbarclay/parinfer-rust-mode.git
(add-to-list 'load-path "/path/to/parinfer-rust-mode")
(add-hook 'emacs-lisp-mode 'parinfer-rust-mode)
Coming soon?
Key | Command | Description |
---|---|---|
C-c s | parinfer-switch-mode | Quickly switch between paren, indent, and smart modes |
C-c d | Disable parinfer-rust-mode | Sometimes you need to make a change or undo things quickly and the easiest way to accomplish that is with parinfer-rust-mode disabled. |
Parinfer can operate under three different modes when writing lisp.
Paren Mode gives you full control of parens, while Parinfer corrects indentation. You can still adjust indentation, but you won’t be able to indent/dedent past certain boundaries set by parens on previous lines.
Indent Mode gives you full control of indentation, while Parinfer corrects or inserts close-parens where appropriate. Specifically, it only touches the groups of close-parens at the end of each line.
Smart Mode is like Indent Mode, but it tries to preserve the structure too.
There is an alternate implementation of Parinfer for Emacs called parinfer-mode. It currently has support for Parinfer’s “paren” and “indent”. Additionally, it has had experimental support for “smart” mode, however, this has remained hidden on a branch and not accessible from MELPA for over a year. parinfer-smart-mode aims to be a simpler adaptation of Parinfer that just offers “smart mode”, leveraging the parinfer-rust plugin to do most of the heavy lifting.
- This is still alpha software and parinfer-rust has been known to get
Out of Memory
warnings and cause Emacs to crash, so use at your own risk. - Multiple cursors do not work as intended
- Does not play well with other modes that insert parens or manage whitespace. If you have modes like electric-pair-mode or hungry-delete-mode enabled, you may want to disable them for any mode that has parinfer-rust-mode enabled. To help users work around this we offer to disable known troublesome modes if we detect them.
- Shaun Lebron for creating Parinfer
- Jason Felice for creating and maintaining the parinfer-rust project
- tianshu for helping me fall in love with parinfer-mode in Emacs.