Skip to content

Commit 7bd2619

Browse files
committed
Fix issue that emacs hangs after def? statements
1 parent 642e146 commit 7bd2619

File tree

2 files changed

+12
-43
lines changed

2 files changed

+12
-43
lines changed

elixir-smie.el

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,7 @@
109109
'((id)
110110
(statements (statement)
111111
(statement ";" statements))
112-
(statement ("def" non-block-expr "do" statements "end")
113-
("defp" non-block-expr "do" statements "end")
114-
("defp" non-block-expr "COMMA" "do:" non-block-expr)
115-
("defmacro" non-block-expr "do" statements "end")
116-
("defmacrop" non-block-expr "do" statements "end")
117-
(non-block-expr "fn" match-statements "end")
112+
(statement (non-block-expr "fn" match-statements "end")
118113
(non-block-expr "do" statements "end")
119114
("if" non-block-expr "do" statements "else" statements "end")
120115
("if" non-block-expr "do" statements "end")
@@ -306,7 +301,7 @@
306301
(elixir-smie--implicit-semi-p))
307302
(if (elixir-smie--semi-ends-match)
308303
"MATCH-STATEMENT-DELIMITER"
309-
(if (and (looking-back ",$" (- (point) 2) t)
304+
(if (and (looking-back ",$" (- (point) 3) t)
310305
(not (> (nth 0 (syntax-ppss)) 0)))
311306
"COMMA"
312307
";")))

test/elixir-mode-indentation-test.el

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,14 +1013,14 @@ end
10131013
(:tags '(indentation))
10141014
"
10151015
def foo do
1016-
case is_string(x) do
1017-
true ->
1018-
x2 = \" one\"
1019-
x <> x2
1020-
false ->
1021-
x2 = \" two\"
1022-
x <> x2
1023-
end
1016+
case is_string(x) do
1017+
true ->
1018+
x2 = \" one\"
1019+
x <> x2
1020+
false ->
1021+
x2 = \" two\"
1022+
x <> x2
1023+
end
10241024
end"
10251025
"
10261026
def foo do
@@ -1549,30 +1549,6 @@ defmodule Foo do
15491549
end
15501550
")
15511551

1552-
(elixir-def-indentation-test complex-case-with-matches
1553-
(:tags '(indentation))
1554-
"
1555-
case parse do
1556-
{ [ help: true ], _, _ }
1557-
-> :help
1558-
{ _, [ user, project, count ], _ } ->
1559-
{ user, project, count }
1560-
{ _, [ user, project ], _ } -> { user, project, @default_count }
1561-
{ _, [ _, project ], _ } -> { _, project, @default_count }
1562-
_ -> :help
1563-
end"
1564-
"
1565-
case parse do
1566-
{ [ help: true ], _, _ }
1567-
-> :help
1568-
{ _, [ user, project, count ], _ } ->
1569-
{ user, project, count }
1570-
{ _, [ user, project ], _ } -> { user, project, @default_count }
1571-
{ _, [ _, project ], _ } -> { _, project, @default_count }
1572-
_ -> :help
1573-
end")
1574-
1575-
15761552
(elixir-def-indentation-test complex-case-with-matches/2
15771553
(:tags '(indentation))
15781554
"
@@ -1668,16 +1644,14 @@ end
16681644
"case statement do
16691645
%{\"foo\" => \"foo\",
16701646
\"baz\" => \"baz\"} ->
1671-
:ok
1672-
1673-
_ ->
1647+
:ok
1648+
_ ->
16741649
:ok
16751650
end"
16761651
"case statement do
16771652
%{\"foo\" => \"foo\",
16781653
\"baz\" => \"baz\"} ->
16791654
:ok
1680-
16811655
_ ->
16821656
:ok
16831657
end")

0 commit comments

Comments
 (0)