[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 131cebb 055/486: Fix regression of multi-line st
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 131cebb 055/486: Fix regression of multi-line statement indents |
Date: |
Sat, 7 Aug 2021 09:24:47 -0400 (EDT) |
branch: elpa/rust-mode
commit 131cebba67c27ca5b632b80a49a5568be39a10a7
Author: Micah Chalmer <micah@micahchalmer.net>
Commit: Micah Chalmer <micah@micahchalmer.net>
Fix regression of multi-line statement indents
---
rust-mode-tests.el | 12 ++++++++++++
rust-mode.el | 47 ++++++++++++++++++++++++-----------------------
2 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index a7cb261..ac5b1b1 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -378,3 +378,15 @@ fn nexted_fns(a: fn(b:int,
}
"
))
+
+(ert-deftest indent-multi-line-expr ()
+ (test-indent
+ "
+fn foo()
+{
+ x();
+ let a =
+ b();
+}
+"
+))
diff --git a/rust-mode.el b/rust-mode.el
index e809a34..a61d916 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -48,13 +48,12 @@
(if (/= starting (point))
(rust-rewind-irrelevant))))
-(defun rust-first-indent-after-brace ()
+(defun rust-align-to-expr-after-brace ()
(save-excursion
(forward-char)
- (if (looking-at "[[:blank:]]*\\(?://.*\\)?$")
- ;; We don't want to indent out to the open bracket if the
- ;; open bracket ends the line
- (* rust-indent-offset (rust-paren-level))
+ ;; We don't want to indent out to the open bracket if the
+ ;; open bracket ends the line
+ (when (not (looking-at "[[:blank:]]*\\(?://.*\\)?$"))
(when (looking-at "[[:space:]]") (forward-to-word 1))
(current-column))))
@@ -69,7 +68,8 @@
((looking-at "->")
(save-excursion
(backward-list)
- (rust-first-indent-after-brace)))
+ (or (rust-align-to-expr-after-brace)
+ (* rust-indent-offset (+ 1 level)))))
;; A closing brace is 1 level unindended
((looking-at "}") (* rust-indent-offset (- level 1)))
@@ -91,24 +91,25 @@
(let ((pt (point)))
(rust-rewind-irrelevant)
(backward-up-list)
- (if (looking-at "[[({]")
- (rust-first-indent-after-brace)
- (progn
- (goto-char pt)
- (back-to-indentation)
- (if (looking-at "\\<else\\>")
- (* rust-indent-offset (+ 1 level))
- (progn
- (goto-char pt)
- (beginning-of-line)
- (rust-rewind-irrelevant)
- (end-of-line)
- (if (looking-back "[[,;{}(][[:space:]]*\\(?://.*\\)?")
- (* rust-indent-offset level)
- (back-to-indentation)
- (if (looking-at "#")
+ (or (and (looking-at "[[({]")
+ (rust-align-to-expr-after-brace))
+ (progn
+ (goto-char pt)
+ (back-to-indentation)
+ (if (looking-at "\\<else\\>")
+ (* rust-indent-offset (+ 1 level))
+ (progn
+ (goto-char pt)
+ (beginning-of-line)
+ (rust-rewind-irrelevant)
+ (end-of-line)
+ (if (looking-back
+ "[[,;{}(][[:space:]]*\\(?://.*\\)?")
(* rust-indent-offset level)
- (* rust-indent-offset (+ 1 level))))))))))
+ (back-to-indentation)
+ (if (looking-at "#")
+ (* rust-indent-offset level)
+ (* rust-indent-offset (+ 1 level))))))))))
;; Otherwise we're in a column-zero definition
(t 0))))))
- [nongnu] elpa/rust-mode 1076b9c 035/486: Note incompatibility with global-whitespace-mode., (continued)
- [nongnu] elpa/rust-mode 1076b9c 035/486: Note incompatibility with global-whitespace-mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e976207 029/486: emacs mode: Highlight 'foo as a lifetime, not a character constant., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f962be4 038/486: rust-mode: make indentation customizable, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5488368 039/486: compilation error regexp specific to rustc., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0a81930 041/486: extend file regexp to match files with embedded spaces., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6a6dc4e 042/486: fix typo in rust-mode.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5b34e59 053/486: Add paragraph fill and auto-fill for multi-line comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 69811ea 052/486: Add custom group for rust-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0bf2920 048/486: Fix glitches with struct field aligned indents, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d6b2c32 060/486: Add Imenu support for rust-mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 131cebb 055/486: Fix regression of multi-line statement indents,
ELPA Syncer <=
- [nongnu] elpa/rust-mode b5de342 070/486: Fix typo in emacs ERT test, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode fa51087 057/486: Minor cleanup and formatting tweaks to the rust-mode README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4e0a334 081/486: emacs: do not highlight `#foo]` as an attribute, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2d12c3e 072/486: Emacs: always jump the cursor if needed on indent, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5ebe4c7 080/486: emacs: highlight `macro_name!` in macro invocations using [] delimiters, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 76bcb8d 074/486: etc: attempts at fixing editor highlighting for new attribute syntax, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a59ef8e 090/486: Fix spelling mistakes in comments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9c0846a 101/486: Add test for '\'' single quote char literal, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 55080f6 100/486: Fix syntax and highlighting for char literals, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8a69f69 104/486: Use old code style for emacs 23 compat, ELPA Syncer, 2021/08/07