A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/justinbarclay/parinfer-rust-mode below:

justinbarclay/parinfer-rust-mode: Simplifying how you write Lisp

Parinfer is a plugin that aims to make writing lisp simple. This library is a minimalistic wrapper around justinbarclay/parinfer-rust-emacs, an Emacs-centric fork of eraserhd/parinfer-rust, to provide an Emacs minor mode. parinfer-rust-mode aims to be a simple implementation of Parinfer that leverages the parinfer-rust plugin to do most of the heavy lifting.

Warning

Version 0.9 and greater of parinfer-rust-mode only supports my fork of parinfer-rust, parinfer-rust-emacs. My primary reason for forking was to add better support for parinfer-rust options, which will allow parinfer-rust-mode to work better with non-clojure-like lisps. You can read more here.

For those wanting to continue using parinfer-rust, you should pin your install to version 0.8.5.

  1. Emacs (26+) compiled with Dynamic Module support.
  2. Running on MacOS/Linux, with Windows support coming soon.
  3. (Optional) Curl - to download the library for you

You can install parinfer-rust-mode from source (this github repo)

cd /path/for/elisp-packages
git clone git@github.com:justinbarclay/parinfer-rust-mode.git

After that add it to your load path and go wild.

(add-to-list 'load-path "/path/to/parinfer-rust-mode")
(require 'parinfer-rust-mode)
(add-hook 'emacs-lisp-mode 'parinfer-rust-mode)

Alternatively, you can tell something like use-package to manage it for you.

(use-package parinfer-rust-mode
  :hook emacs-lisp-mode)

You’ll also need to have the library installed on your system for you somewhere.

Option 1: Let Parinfer Rust install it for you

That’s it. There are no instructions here. When parinfer-rust-mode prompts you to download the library, say yes. parinfer-rust-mode will then use curl to download parinfer-rust and save it in ${EMACS_DIRECTORY}/parinfer-rust/.

Supported OS & Arch[fn:1]

Operating System Architecture Windows x86_64 Darwin aarch64 Linux x86_64 Freebsd x86_64

List of supported operating systems and the architecture for which libraries are prebuilt

If you’re curious, you can find the library files that parinfer-rust-mode downloads as release artifacts for parinfer-rust-emacs.

If you would always like parinfer-rust-mode to keep the library version in sync for you, automatically download it, then add the following line into your config:

(setq parinfer-rust-auto-download t)

If you are using the ==use-package== snippet from above, that would look like:

(use-package parinfer-rust-mode
    :hook emacs-lisp-mode
    :init
    (setq parinfer-rust-auto-download t))

[fn:1] Don’t see your OS/Arch on here? Feel free to open up a PR at parinfer-rust-emacs and add your OS to the GitHub actions.

Option 2: Building library from sources

For the more adventurous, you can also download and compile the parinfer-rust library from source.

Step 1: Build the Parinfer Rust Emacs library

When manually compiling the library, the file 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 its 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/justinbarclay/parinfer-rust-emacs.git
cd parinfer-rust
cargo build --release
cp ./target/release/${library-name} ~/.emacs.d/parinfer-rust/${lib-name}
Step 2: Configure parinfer-rust-mode

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")

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.

Command Description parinfer-rust-switch-mode Quickly switch between paren, indent, and smart modes parinfer-rust-toggle-disable Toggle parinfer-rust-mode mode on or off parinfer-rust-toggle-paren-mode Toggle between paren mode and current mode

These commands are no longer bound to the C-c C-p prefix keys by default. If you prefer to use the old bindings, add this to your configuration (keep in mind it may clash with some major mode bindings):

(define-key parinfer-rust-mode-map (kbd "C-c C-p t") #'parinfer-rust-toggle-paren-mode)
(define-key parinfer-rust-mode-map (kbd "C-c C-p s") #'parinfer-rust-switch-mode)
(define-key parinfer-rust-mode-map (kbd "C-c C-p d") #'parinfer-rust-toggle-disable)

parinfer-rust-mode is purposefully light on option, but it does give a few options to tweak behavior.

Options:

default: defer

parinfer-rust-mode uses flycheck and flymake to report parsing errors.

There should be no config needed to work in ==flymake-mode== is enabled.

parinfer-rust-mode is set-up to be chained with the ==emacs-lisp== checker.

However, if you want it to work alongside other checkers you’ll need to chain it yourself.

(use-package parinfer-rust-mode
  :config
  (flycheck-add-next-checker 'emacs-lisp 'parinfer-rust t))

If neither Flycheck or Flymake are enabled then ==parinfer-rust-mode== will output the error to ==*Messages*== buffer.

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.

Sometimes parinfer-rust-mode can get confused when interacting with some minor modes or certain commands. Check out the wiki for known issues.

In some cases, parinfer-rust-mode can misbehave by making the wrong choices. When that happens I recommend you file a bug report. If you want to make my life easier, I recommend following these two as some pretty great examples on how to file a bug report.

If you’d like to help contribute to the development of parinfer-rust-mode the only caveat interesting section of note is the testing framework.

parinfer-rust-mode relies on Cask to manage development libraries and to set-up the tests themselves.

Then after you have made some changes just run:

PARINFER_RUST_TEST=true make test

And you should get something like:

✦ ❯ PARINFER_RUST_TEST=true make test
emacs --version
GNU Emacs 28.0.50
Copyright (C) 2020 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
cask build
Compiling /home/justin/dev/parinfer-rust-mode/parinfer-helper.el...
Compiling /home/justin/dev/parinfer-rust-mode/parinfer-rust-mode-autoloads.el...
Compiling /home/justin/dev/parinfer-rust-mode/parinfer-rust-mode.el...

In toplevel form:
parinfer-rust-mode.el:72:1: Error: Symbol’s value as variable is void: parinfer-rust-library
Compiling /home/justin/dev/parinfer-rust-mode/test-helper.el...
cask exec ert-runner test/**.el --quiet
...............................................................................................................................................

Ran 143 tests in 0.061 seconds

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4