[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 5f37343 379/486: Add rust-indent-return-type-to-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 5f37343 379/486: Add rust-indent-return-type-to-arguments variable |
Date: |
Sat, 7 Aug 2021 09:25:57 -0400 (EDT) |
branch: elpa/rust-mode
commit 5f3734314de0e38f472740dfeeb0102ddc5d0b2c
Author: David Kellum <dek-oss@gravitext.com>
Commit: David Kellum <dek-oss@gravitext.com>
Add rust-indent-return-type-to-arguments variable
This preserves as default (t), the current indentation behavior of `->
ReturnType` when found on its own line: indenting as per the arguments
of the above function. When disabled (nil) by the user, however, this
will now just indent such a line one level from base-line (e.g. no
special treatment).
Includes a basic test.
---
rust-mode-tests.el | 11 +++++++++++
rust-mode.el | 13 +++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 9d87960..a5fea28 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -450,6 +450,17 @@ fn foo4(a:i32,
}
"))
+(ert-deftest indent-return-type-non-visual ()
+ (let ((rust-indent-return-type-to-arguments nil))
+(test-indent
+ "
+fn imagine_long_enough_to_wrap_at_arrow(a:i32, b:char)
+ -> i32
+{
+ let body;
+}
+")))
+
(ert-deftest indent-body-after-where ()
(let ((rust-indent-where-clause t))
(test-indent
diff --git a/rust-mode.el b/rust-mode.el
index a8af671..a433d8d 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -131,6 +131,13 @@ When nil, `where' will be aligned with `fn' or `trait'."
:group 'rust-mode
:safe #'booleanp)
+(defcustom rust-indent-return-type-to-arguments t
+ "Indent a line starting with the `->' (RArrow) following a function, aligning
+to the function arguments. When nil, `->' will be indented one level."
+ :type 'boolean
+ :group 'rust-mode
+ :safe #'booleanp)
+
(defcustom rust-playpen-url-format "https://play.rust-lang.org/?code=%s"
"Format string to use when submitting code to the playpen."
:type 'string
@@ -399,8 +406,10 @@ buffer."
(back-to-indentation)
(current-column))))))
- ;; A function return type is indented to the corresponding
function arguments
- ((looking-at "->")
+ ;; A function return type is indented to the corresponding
+ ;; function arguments, if -to-arguments is selected.
+ ((and rust-indent-return-type-to-arguments
+ (looking-at "->"))
(save-excursion
(backward-list)
(or (rust-align-to-expr-after-brace)
- [nongnu] elpa/rust-mode 758ab8c 303/486: Add support for "default" keyword, (continued)
- [nongnu] elpa/rust-mode 758ab8c 303/486: Add support for "default" keyword, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a73e9ee 004/486: Update reserved words for syntax highlighters (vim is still behind, though), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7724813 306/486: Merge pull request #206 from cjhowe7/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ac6a45e 308/486: Merge pull request #213 from KeenS/restore-points, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d38bfb8 309/486: Set `compile-command' in `rust-mode'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c00c8a9 312/486: Require `json'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 90f70ac 328/486: Use `font-lock-variable-name-face' for `let' bindings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9eda807 341/486: Merge pull request #239 from shepmaster/no-more-int-float, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1275a19 363/486: make rustc-colon-compilation-regexps an info type, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9154e0e 372/486: silence byte-compiler, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5f37343 379/486: Add rust-indent-return-type-to-arguments variable,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 8cd18cc 385/486: Merge pull request #293 from TristanCacqueray/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode df31a6e 393/486: Don't call syntax-ppss twice for strings ending with r., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 942d465 398/486: Update Debian installation instructions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode af84c0f 403/486: Merge pull request #319 from phillord/feature/update-emacs-versions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4c8754b 430/486: Merge pull request #343 from haroldcarr/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4381a89 433/486: Fix scrolling after rustfmt. (#351), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2a8ca9e 443/486: rust-format-show-buffer: default to true., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 15d31a9 013/486: removed a comma from the keyword list to get, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e39142b 033/486: Allow customization of indent offset, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8dc92b2 073/486: Update emacs mode to support new `#![inner(attribute)]` syntax., ELPA Syncer, 2021/08/07