Skip to content

Commit 10b83c5

Browse files
committed
---
yaml --- r: 144572 b: refs/heads/try2 c: 7a42dd8 h: refs/heads/master v: v3
1 parent 43c3b4a commit 10b83c5

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 70bc1637b877f52f824b34bbfbf73936d52a628e
8+
refs/heads/try2: 7a42dd807430f11678e004bbbad9eda3a550dea9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/emacs/rust-mode.el

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
;; Url: https://github.com/mozilla/rust
66

77
(eval-when-compile (require 'cl))
8+
(eval-when-compile (require 'misc))
89

910
;; Syntax definitions and helpers
1011
(defvar rust-mode-syntax-table
@@ -67,20 +68,29 @@
6768
;; or one further indent from that if either current line
6869
;; begins with 'else', or previous line didn't end in
6970
;; semi, comma or brace (other than whitespace and line
70-
;; comments) , and wasn't an attribute. PHEW.
71+
;; comments) , and wasn't an attribute. But if we have
72+
;; something after the open brace and ending with a comma,
73+
;; treat it as fields and align them. PHEW.
7174
((> level 0)
7275
(let ((pt (point)))
7376
(rust-rewind-irrelevant)
7477
(backward-up-list)
75-
(if (and
78+
(cond
79+
((and
7680
(looking-at "[[(]")
7781
; We don't want to indent out to the open bracket if the
7882
; open bracket ends the line
7983
(save-excursion
8084
(forward-char)
8185
(not (looking-at "[[:space:]]*\\(?://.*\\)?$"))))
82-
(+ 1 (current-column))
86+
(+ 1 (current-column)))
87+
;; Check for fields on the same line as the open curly brace:
88+
((looking-at "{[[:blank:]]*[^}\n]*,[[:space:]]*$")
8389
(progn
90+
(forward-char)
91+
(forward-to-word 1)
92+
(current-column)))
93+
(t (progn
8494
(goto-char pt)
8595
(back-to-indentation)
8696
(if (looking-at "\\<else\\>")
@@ -95,7 +105,7 @@
95105
(back-to-indentation)
96106
(if (looking-at "#")
97107
(* rust-indent-offset level)
98-
(* rust-indent-offset (+ 1 level))))))))))
108+
(* rust-indent-offset (+ 1 level)))))))))))
99109

100110
;; Otherwise we're in a column-zero definition
101111
(t 0))))))

0 commit comments

Comments
 (0)