|
1 |
| -`rust-mode`: A major Emacs mode for editing Rust source code |
2 |
| -============================================================ |
| 1 | +[](https://melpa.org/#/rust-mode) |
3 | 2 |
|
4 |
| -`rust-mode` makes editing [Rust](http://rust-lang.org) code with Emacs |
5 |
| -enjoyable. `rust-mode` requires Emacs 24 or later. |
6 |
| - |
7 |
| -## Installation |
8 |
| - |
9 |
| -### Manual Installation |
| 3 | +# Emacs mode for editing Rust source code |
10 | 4 |
|
11 |
| -To install manually, check out this repository and add this to your |
12 |
| -`.emacs` file: |
| 5 | +<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> |
| 6 | +**Table of Contents** |
13 | 7 |
|
14 |
| -```lisp |
15 |
| -(add-to-list 'load-path "/path/to/rust-mode/") |
16 |
| -(autoload 'rust-mode "rust-mode" nil t) |
17 |
| -(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)) |
18 |
| -``` |
| 8 | +- [Installation via MELPA](#installation-via-melpa) |
| 9 | +- [Manual Installation](#manual-installation) |
| 10 | +- [rustfmt](#rustfmt) |
| 11 | +- [Tests](#tests) |
| 12 | +- [Other useful packages](#other-useful-packages) |
19 | 13 |
|
20 |
| -This associates `rust-mode` with `.rs` files. To enable it explicitly, do |
21 |
| -<kbd>M-x rust-mode</kbd>. |
| 14 | +<!-- markdown-toc end --> |
22 | 15 |
|
23 |
| -### `package.el` installation via MELPA |
| 16 | +# Installation via MELPA |
24 | 17 |
|
25 |
| -It can be more convenient to use Emacs's package manager to handle |
26 |
| -installation for you if you use many elisp libraries. If you have |
27 |
| -`package.el` but haven't added MELPA, the community |
28 |
| -package source, yet, add this to `~/.emacs.d/init.el`: |
| 18 | +`rust-mode` makes editing [Rust](http://rust-lang.org) code with Emacs |
| 19 | +enjoyable. It requires Emacs 24 or later. |
| 20 | +The package is available on MELPA. Add this to your init.el. |
29 | 21 |
|
30 |
| -```lisp |
| 22 | +``` elisp |
31 | 23 | (require 'package)
|
32 | 24 | (add-to-list 'package-archives
|
33 | 25 | '("melpa" . "https://melpa.org/packages/") t)
|
34 | 26 | (package-initialize)
|
| 27 | +(package-refresh-contents) |
35 | 28 | ```
|
36 | 29 |
|
37 |
| -Then do this to load the package listing: |
38 |
| - |
39 |
| -* <kbd>M-x eval-buffer</kbd> |
40 |
| -* <kbd>M-x package-refresh-contents</kbd> |
| 30 | +Now you can install `rust-mode` with: |
41 | 31 |
|
42 |
| -#### MELPA stable |
| 32 | +`M-x package-install rust-mode` |
43 | 33 |
|
44 |
| -MELPA stable only updates when a new version tag is created. There isn't a |
45 |
| -specified frequency for this project to release versions; if you are a MELPA |
46 |
| -stable user and feel that the last release tag is too far out of date, open a |
47 |
| -pull request that updates the version header in `rust-mode.el` and note that a |
48 |
| -new version tag should be added when the request is merged. |
49 |
| -See [Pull Request #178](https://github.com/rust-lang/rust-mode/pull/178) (the |
50 |
| -first such pull request)) for an example of this. |
| 34 | +And put this in your config to load rust-mode automatically: |
51 | 35 |
|
52 |
| -#### Install `rust-mode` |
| 36 | +`(require 'rust-mode)` |
53 | 37 |
|
54 |
| -One you have `package.el`, you can install `rust-mode` or any other |
55 |
| -modes by choosing them from a list: |
| 38 | +# Manual Installation |
56 | 39 |
|
57 |
| -* <kbd>M-x package-list-packages</kbd> |
| 40 | +Add this to your init.el: |
58 | 41 |
|
59 |
| -Now, to install packages, move your cursor to them and press |
60 |
| -<kbd>i</kbd>. This will mark the packages for installation. When |
61 |
| -you're done with marking, press <kbd>x</kbd>, and ELPA will install |
62 |
| -the packages for you (under `~/.emacs.d/elpa/`). |
| 42 | +``` elisp |
| 43 | +(add-to-list 'load-path "/path/to/rust-mode/") |
| 44 | +(autoload 'rust-mode "rust-mode" nil t) |
| 45 | +``` |
63 | 46 |
|
64 |
| -* or using <kbd>M-x package-install rust-mode</kbd> |
| 47 | +# rustfmt |
65 | 48 |
|
66 |
| -### Package installation on Debian |
| 49 | +The `rust-format-buffer` function will format your code with |
| 50 | +[rustfmt](https://github.com/rust-lang/rustfmt) if installed. By default, |
| 51 | +this is bound to `C-c C-f`. |
67 | 52 |
|
68 |
| -```bash |
69 |
| -apt install elpa-rust-mode |
70 |
| -``` |
| 53 | +Placing `(setq rust-format-on-save t)` in your init.el will enable automatic |
| 54 | +running of `rust-format-buffer` when you save a buffer. |
71 | 55 |
|
72 |
| -### Tests via ERT |
| 56 | +# Tests |
73 | 57 |
|
74 | 58 | The file `rust-mode-tests.el` contains tests that can be run via
|
75 | 59 | [ERT](http://www.gnu.org/software/emacs/manual/html_node/ert/index.html).
|
76 | 60 | You can use `run_rust_emacs_tests.sh` to run them in batch mode, if
|
77 | 61 | you set the environment variable EMACS to a program that runs emacs.
|
78 | 62 |
|
79 |
| -## Features |
80 |
| - |
81 |
| -### Formatting with [rustfmt][rfmt] |
82 |
| - |
83 |
| -The `rust-format-buffer` function will format your code with |
84 |
| -[rustfmt][rfmt] if installed. By default, this is bound to `C-c C-f`. |
85 |
| - |
86 |
| -Placing `(setq rust-format-on-save t)` in your `~/.emacs` will enable automatic |
87 |
| -running of `rust-format-buffer` when you save a buffer. |
88 |
| - |
89 |
| -[rfmt]: https://crates.io/crates/rustfmt/ |
90 |
| - |
91 |
| -## License |
92 |
| - |
93 |
| -`rust-mode` is distributed under the terms of both the MIT license and the |
94 |
| -Apache License (Version 2.0). |
| 63 | +# Other useful packages |
95 | 64 |
|
96 |
| -See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for details. |
| 65 | +[cargo.el](https://github.com/kwrooijen/cargo.el) Emacs Minor Mode for Cargo, Rust's Package Manager |
| 66 | +[emacs-racer](https://github.com/racer-rust/emacs-racer) Racer support for Emacs |
| 67 | +[rustic](https://github.com/brotzeit/rustic) Rust development environment for Emacs |
0 commit comments