|
48 | 48 | (if (/= starting (point)) |
49 | 49 | (rust-rewind-irrelevant)))) |
50 | 50 |
|
51 | | -(defun rust-first-indent-after-brace () |
| 51 | +(defun rust-align-to-expr-after-brace () |
52 | 52 | (save-excursion |
53 | 53 | (forward-char) |
54 | | - (if (looking-at "[[:blank:]]*\\(?://.*\\)?$") |
55 | | - ;; We don't want to indent out to the open bracket if the |
56 | | - ;; open bracket ends the line |
57 | | - (* rust-indent-offset (rust-paren-level)) |
| 54 | + ;; We don't want to indent out to the open bracket if the |
| 55 | + ;; open bracket ends the line |
| 56 | + (when (not (looking-at "[[:blank:]]*\\(?://.*\\)?$")) |
58 | 57 | (when (looking-at "[[:space:]]") (forward-to-word 1)) |
59 | 58 | (current-column)))) |
60 | 59 |
|
|
69 | 68 | ((looking-at "->") |
70 | 69 | (save-excursion |
71 | 70 | (backward-list) |
72 | | - (rust-first-indent-after-brace))) |
| 71 | + (or (rust-align-to-expr-after-brace) |
| 72 | + (* rust-indent-offset (+ 1 level))))) |
73 | 73 |
|
74 | 74 | ;; A closing brace is 1 level unindended |
75 | 75 | ((looking-at "}") (* rust-indent-offset (- level 1))) |
|
91 | 91 | (let ((pt (point))) |
92 | 92 | (rust-rewind-irrelevant) |
93 | 93 | (backward-up-list) |
94 | | - (if (looking-at "[[({]") |
95 | | - (rust-first-indent-after-brace) |
96 | | - (progn |
97 | | - (goto-char pt) |
98 | | - (back-to-indentation) |
99 | | - (if (looking-at "\\<else\\>") |
100 | | - (* rust-indent-offset (+ 1 level)) |
101 | | - (progn |
102 | | - (goto-char pt) |
103 | | - (beginning-of-line) |
104 | | - (rust-rewind-irrelevant) |
105 | | - (end-of-line) |
106 | | - (if (looking-back "[[,;{}(][[:space:]]*\\(?://.*\\)?") |
107 | | - (* rust-indent-offset level) |
108 | | - (back-to-indentation) |
109 | | - (if (looking-at "#") |
| 94 | + (or (and (looking-at "[[({]") |
| 95 | + (rust-align-to-expr-after-brace)) |
| 96 | + (progn |
| 97 | + (goto-char pt) |
| 98 | + (back-to-indentation) |
| 99 | + (if (looking-at "\\<else\\>") |
| 100 | + (* rust-indent-offset (+ 1 level)) |
| 101 | + (progn |
| 102 | + (goto-char pt) |
| 103 | + (beginning-of-line) |
| 104 | + (rust-rewind-irrelevant) |
| 105 | + (end-of-line) |
| 106 | + (if (looking-back |
| 107 | + "[[,;{}(][[:space:]]*\\(?://.*\\)?") |
110 | 108 | (* rust-indent-offset level) |
111 | | - (* rust-indent-offset (+ 1 level)))))))))) |
| 109 | + (back-to-indentation) |
| 110 | + (if (looking-at "#") |
| 111 | + (* rust-indent-offset level) |
| 112 | + (* rust-indent-offset (+ 1 level)))))))))) |
112 | 113 |
|
113 | 114 | ;; Otherwise we're in a column-zero definition |
114 | 115 | (t 0)))))) |
|
0 commit comments