[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 3301c70 047/486: Align field names in struct exp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 3301c70 047/486: Align field names in struct expressions with fields on same line as the opening curly brace |
Date: |
Sat, 7 Aug 2021 09:24:45 -0400 (EDT) |
branch: elpa/rust-mode
commit 3301c707f32c48a75f970e1e9c21fa5d011cb50d
Author: Micah Chalmer <micah@micahchalmer.net>
Commit: Micah Chalmer <micah@micahchalmer.net>
Align field names in struct expressions with fields on same line as the
opening curly brace
---
rust-mode.el | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/rust-mode.el b/rust-mode.el
index 5c94f6f..92b8524 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -5,6 +5,7 @@
;; Url: https://github.com/mozilla/rust
(eval-when-compile (require 'cl))
+(eval-when-compile (require 'misc))
;; Syntax definitions and helpers
(defvar rust-mode-syntax-table
@@ -67,20 +68,29 @@
;; or one further indent from that if either current line
;; begins with 'else', or previous line didn't end in
;; semi, comma or brace (other than whitespace and line
- ;; comments) , and wasn't an attribute. PHEW.
+ ;; comments) , and wasn't an attribute. But if we have
+ ;; something after the open brace and ending with a comma,
+ ;; treat it as fields and align them. PHEW.
((> level 0)
(let ((pt (point)))
(rust-rewind-irrelevant)
(backward-up-list)
- (if (and
+ (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))
+ (+ 1 (current-column)))
+ ;; Check for fields on the same line as the open curly brace:
+ ((looking-at "{[[:blank:]]*[^}\n]*,[[:space:]]*$")
(progn
+ (forward-char)
+ (forward-to-word 1)
+ (current-column)))
+ (t (progn
(goto-char pt)
(back-to-indentation)
(if (looking-at "\\<else\\>")
@@ -95,7 +105,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] elpa/rust-mode 01db4cb 225/486: Fix font-locking for Unicode escapes in character literals., (continued)
- [nongnu] elpa/rust-mode 01db4cb 225/486: Fix font-locking for Unicode escapes in character literals., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b874bbe 213/486: Merge pull request #113 from MicahChalmer/fix-issue-104, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2cd3cf9 216/486: Merge pull request #116 from Wilfred/type_annotation_highlighting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3517321 230/486: Merge pull request #129 from MicahChalmer/fix-issue-127, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8400638 241/486: update README.md and Package-Requires to require emacs 24, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c3feac1 243/486: Fill regular block comments correctly too, in addition to rustdoc comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1587839 268/486: Merge pull request #169 from mrBliss/fix-168, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 664c7b0 277/486: improve position recovery in rust-format-buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 46e7fc0 285/486: fix PR link in README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 35298ed 288/486: Don't use "&optional &rest", ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3301c70 047/486: Align field names in struct expressions with fields on same line as the opening curly brace,
ELPA Syncer <=
- [nongnu] elpa/rust-mode fe55b71 046/486: Multiline comments with leading *s line up the *s, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode af2aba9 049/486: Indent correctly after opening square bracket, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b83aabf 054/486: Add ERT tests, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 38dab12 063/486: Fix rust-align-to-expr-after-brace, closes #11239., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7625c5c 058/486: Add 'continue' keyword to emacs, vim, gedit, kate, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d82b5a7 062/486: Add "proc" as keyword to emacs mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 891716a 059/486: Fix single-line-style paragraph fills with code immediately before or after, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6b323f3 064/486: Add crate to emacs and kate modefiles, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4f40156 071/486: Emacs: Remove README warning of old whitespace bug, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ef048b3 082/486: emacs: highlight `#[foo = "bar"]` attributes, ELPA Syncer, 2021/08/07