Skip to content

Commit bfa3e1b

Browse files
committed
Flesh out rules for MSD.
1 parent 3fbb91a commit bfa3e1b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

elixir-smie.el

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,35 @@
148148
((smie-rule-sibling-p) nil)
149149
((smie-rule-hanging-p) (smie-rule-parent elixir-smie-indent-basic))
150150
(t elixir-smie-indent-basic)))
151+
151152
(`(:before . "MATCH-STATEMENT-DELIMITER")
152-
(if (smie-rule-sibling-p)
153-
(smie-rule-parent)))
153+
(cond
154+
((and (not (smie-rule-sibling-p))
155+
(smie-rule-hanging-p))
156+
(smie-rule-parent elixir-smie-indent-basic))
157+
((and (smie-rule-hanging-p)
158+
(smie-rule-sibling-p))
159+
(smie-rule-parent))))
160+
154161
(`(:after . "MATCH-STATEMENT-DELIMITER")
155-
(smie-rule-parent elixir-smie-indent-basic))
162+
(cond
163+
;; We don't want to specify any rules for the first `->' after `do' or
164+
;; `fn', since SMIE will look at the BNF to see how to handle indentation
165+
;; in that case.
166+
((and (not (smie-rule-parent-p "fn" "do"))
167+
(smie-rule-hanging-p))
168+
(smie-rule-parent elixir-smie-indent-basic))
169+
((smie-rule-parent-p "fn" "do")
170+
elixir-smie-indent-basic)))
171+
156172
(`(:before . ";")
157173
(cond
158174
((smie-rule-parent-p "after" "catch" "def" "defmodule" "defp" "do" "else"
159175
"fn" "if" "rescue" "try" "unless")
160176
(smie-rule-parent elixir-smie-indent-basic))))
161177
(`(:after . ";")
162178
(if (smie-rule-parent-p "if")
163-
(smie-rule-parent 0)))))
179+
(smie-rule-parent)))))
164180

165181
(define-minor-mode elixir-smie-mode
166182
"SMIE-based indentation and syntax for Elixir"

0 commit comments

Comments
 (0)