Skip to content

Commit 8e77a84

Browse files
committed
Merge pull request #364 from elixir-lang/fix-hang-after-do
Fix issue that emacs hangs after def? statements
2 parents fe313d3 + 7bd2619 commit 8e77a84

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
@@ -115,12 +115,7 @@
115115
'((id)
116116
(statements (statement)
117117
(statement ";" statements))
118-
(statement ("def" non-block-expr "do" statements "end")
119-
("defp" non-block-expr "do" statements "end")
120-
("defp" non-block-expr "COMMA" "do:" non-block-expr)
121-
("defmacro" non-block-expr "do" statements "end")
122-
("defmacrop" non-block-expr "do" statements "end")
123-
(non-block-expr "fn" match-statements "end")
118+
(statement (non-block-expr "fn" match-statements "end")
124119
(non-block-expr "do" statements "end")
125120
("if" non-block-expr "do" statements "else" statements "end")
126121
("if" non-block-expr "do" statements "end")
@@ -312,7 +307,7 @@
312307
(elixir-smie--implicit-semi-p))
313308
(if (elixir-smie--semi-ends-match)
314309
"MATCH-STATEMENT-DELIMITER"
315-
(if (and (looking-back ",$" (- (point) 2) t)
310+
(if (and (looking-back ",$" (- (point) 3) t)
316311
(not (> (nth 0 (syntax-ppss)) 0)))
317312
"COMMA"
318313
";")))

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
@@ -1566,30 +1566,6 @@ defmodule Foo do
15661566
end
15671567
")
15681568

1569-
(elixir-def-indentation-test complex-case-with-matches
1570-
(:tags '(indentation))
1571-
"
1572-
case parse do
1573-
{ [ help: true ], _, _ }
1574-
-> :help
1575-
{ _, [ user, project, count ], _ } ->
1576-
{ user, project, count }
1577-
{ _, [ user, project ], _ } -> { user, project, @default_count }
1578-
{ _, [ _, project ], _ } -> { _, project, @default_count }
1579-
_ -> :help
1580-
end"
1581-
"
1582-
case parse do
1583-
{ [ help: true ], _, _ }
1584-
-> :help
1585-
{ _, [ user, project, count ], _ } ->
1586-
{ user, project, count }
1587-
{ _, [ user, project ], _ } -> { user, project, @default_count }
1588-
{ _, [ _, project ], _ } -> { _, project, @default_count }
1589-
_ -> :help
1590-
end")
1591-
1592-
15931569
(elixir-def-indentation-test complex-case-with-matches/2
15941570
(:tags '(indentation))
15951571
"
@@ -1685,16 +1661,14 @@ end
16851661
"case statement do
16861662
%{\"foo\" => \"foo\",
16871663
\"baz\" => \"baz\"} ->
1688-
:ok
1689-
1690-
_ ->
1664+
:ok
1665+
_ ->
16911666
:ok
16921667
end"
16931668
"case statement do
16941669
%{\"foo\" => \"foo\",
16951670
\"baz\" => \"baz\"} ->
16961671
:ok
1697-
16981672
_ ->
16991673
:ok
17001674
end")

0 commit comments

Comments
 (0)