[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 2765de7 050/486: Allow indenting to align struct
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 2765de7 050/486: Allow indenting to align struct fields after curly brace |
Date: |
Sat, 7 Aug 2021 09:24:46 -0400 (EDT) |
branch: elpa/rust-mode
commit 2765de71a30bcd24a9e433add88953148c602444
Author: Micah Chalmer <micah@micahchalmer.net>
Commit: Micah Chalmer <micah@micahchalmer.net>
Allow indenting to align struct fields after curly brace
---
rust-mode.el | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/rust-mode.el b/rust-mode.el
index e45cec9..ff91192 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -45,6 +45,16 @@
(if (/= starting (point))
(rust-rewind-irrelevant))))
+(defun rust-first-indent-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))
+ (when (looking-at "[[:space:]]") (forward-to-word 1))
+ (current-column))))
+
(defun rust-mode-indent-line ()
(interactive)
(let ((indent
@@ -58,7 +68,7 @@
;; A closing brace is 1 level unindended
((looking-at "}") (* rust-indent-offset (- level 1)))
- ; Doc comments in /** style with leading * indent to line up the
*s
+ ;; Doc comments in /** style with leading * indent to line up
the *s
((and (nth 4 (syntax-ppss)) (looking-at "*"))
(+ 1 (* rust-indent-offset level)))
@@ -75,22 +85,9 @@
(let ((pt (point)))
(rust-rewind-irrelevant)
(backward-up-list)
- (cond
- ((and
- (looking-at "[[(]")
- ; We don't want to indent out to the open bracket if the
- ; open bracket ends the line
- (save-excursion
- (forward-char)
- (not (looking-at "[[:space:]]*\\(?://.*\\)?$"))))
- (+ 1 (current-column)))
- ;; Check for fields on the same line as the open curly brace:
- ((looking-at "{[[:space:]]*[^\n]*,[[:space:]]*$")
+ (if (looking-at "[[({]")
+ (rust-first-indent-after-brace)
(progn
- (forward-char)
- (when (looking-at "[[:space:]]") (forward-to-word 1))
- (current-column)))
- (t (progn
(goto-char pt)
(back-to-indentation)
(if (looking-at "\\<else\\>")
@@ -105,7 +102,7 @@
(back-to-indentation)
(if (looking-at "#")
(* rust-indent-offset level)
- (* rust-indent-offset (+ 1 level)))))))))))
+ (* rust-indent-offset (+ 1 level))))))))))
;; Otherwise we're in a column-zero definition
(t 0))))))
- [nongnu] branch elpa/rust-mode created (now 494d59f), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8b8d1ea 022/486: fix indentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c3c5f1c 025/486: emacs mode: include use as a keyword, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4c1eab5 036/486: rewrite rust-mode to use font-lock-mode and emacs builtin syntax analysis, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 12480f9 045/486: One indent after open paren with no argument, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2765de7 050/486: Allow indenting to align struct fields after curly brace,
ELPA Syncer <=
- [nongnu] elpa/rust-mode e9b1bfe 006/486: Add 'do' to rust-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a25cc60 005/486: More keyword paring and migration in runtime, docs, code modes., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode fb23ccc 003/486: emacs: Make 'mut' a keyword, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode de81353 014/486: Merge pull request #3185 from megakorre/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5afc8ab 015/486: initial stab at making rust-mode elpa friendly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7ce29ed 016/486: proper package footer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 38940ff 027/486: rust-mode: Add 'ref' keyword, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9f9dec0 028/486: rust-mode.el uses the 'cl macros, so it should actually require them, ELPA Syncer, 2021/08/07
- [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