Skip to content

Commit b328c63

Browse files
committed
---
yaml --- r: 144865 b: refs/heads/try2 c: 9ef0b9c h: refs/heads/master i: 144863: 784c42a v: v3
1 parent d5093d1 commit b328c63

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
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: 1c527dfcd466d9b5ea75fe199c364837298a4278
8+
refs/heads/try2: 9ef0b9c0d6180f0e5023b29ac57835e6e75517d0
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 & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
(if (/= starting (point))
4646
(rust-rewind-irrelevant))))
4747

48+
(defun rust-first-indent-after-brace ()
49+
(save-excursion
50+
(forward-char)
51+
(if (looking-at "[[:blank:]]*\\(?://.*\\)?$")
52+
;; We don't want to indent out to the open bracket if the
53+
;; open bracket ends the line
54+
(* rust-indent-offset (rust-paren-level))
55+
(when (looking-at "[[:space:]]") (forward-to-word 1))
56+
(current-column))))
57+
4858
(defun rust-mode-indent-line ()
4959
(interactive)
5060
(let ((indent
@@ -58,7 +68,7 @@
5868
;; A closing brace is 1 level unindended
5969
((looking-at "}") (* rust-indent-offset (- level 1)))
6070

61-
; Doc comments in /** style with leading * indent to line up the *s
71+
;; Doc comments in /** style with leading * indent to line up the *s
6272
((and (nth 4 (syntax-ppss)) (looking-at "*"))
6373
(+ 1 (* rust-indent-offset level)))
6474

@@ -75,22 +85,9 @@
7585
(let ((pt (point)))
7686
(rust-rewind-irrelevant)
7787
(backward-up-list)
78-
(cond
79-
((and
80-
(looking-at "[[(]")
81-
; We don't want to indent out to the open bracket if the
82-
; open bracket ends the line
83-
(save-excursion
84-
(forward-char)
85-
(not (looking-at "[[:space:]]*\\(?://.*\\)?$"))))
86-
(+ 1 (current-column)))
87-
;; Check for fields on the same line as the open curly brace:
88-
((looking-at "{[[:space:]]*[^\n]*,[[:space:]]*$")
88+
(if (looking-at "[[({]")
89+
(rust-first-indent-after-brace)
8990
(progn
90-
(forward-char)
91-
(when (looking-at "[[:space:]]") (forward-to-word 1))
92-
(current-column)))
93-
(t (progn
9491
(goto-char pt)
9592
(back-to-indentation)
9693
(if (looking-at "\\<else\\>")
@@ -105,7 +102,7 @@
105102
(back-to-indentation)
106103
(if (looking-at "#")
107104
(* rust-indent-offset level)
108-
(* rust-indent-offset (+ 1 level)))))))))))
105+
(* rust-indent-offset (+ 1 level))))))))))
109106

110107
;; Otherwise we're in a column-zero definition
111108
(t 0))))))

0 commit comments

Comments
 (0)