Skip to content

Fix issue that emacs hangs after def? statements #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions elixir-smie.el
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,7 @@
'((id)
(statements (statement)
(statement ";" statements))
(statement ("def" non-block-expr "do" statements "end")
("defp" non-block-expr "do" statements "end")
("defp" non-block-expr "COMMA" "do:" non-block-expr)
("defmacro" non-block-expr "do" statements "end")
("defmacrop" non-block-expr "do" statements "end")
(non-block-expr "fn" match-statements "end")
(statement (non-block-expr "fn" match-statements "end")
(non-block-expr "do" statements "end")
("if" non-block-expr "do" statements "else" statements "end")
("if" non-block-expr "do" statements "end")
Expand Down Expand Up @@ -306,7 +301,7 @@
(elixir-smie--implicit-semi-p))
(if (elixir-smie--semi-ends-match)
"MATCH-STATEMENT-DELIMITER"
(if (and (looking-back ",$" (- (point) 2) t)
(if (and (looking-back ",$" (- (point) 3) t)
(not (> (nth 0 (syntax-ppss)) 0)))
"COMMA"
";")))
Expand Down
46 changes: 10 additions & 36 deletions test/elixir-mode-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1013,14 +1013,14 @@ end
(:tags '(indentation))
"
def foo do
case is_string(x) do
true ->
x2 = \" one\"
x <> x2
false ->
x2 = \" two\"
x <> x2
end
case is_string(x) do
true ->
x2 = \" one\"
x <> x2
false ->
x2 = \" two\"
x <> x2
end
end"
"
def foo do
Expand Down Expand Up @@ -1549,30 +1549,6 @@ defmodule Foo do
end
")

(elixir-def-indentation-test complex-case-with-matches
(:tags '(indentation))
"
case parse do
{ [ help: true ], _, _ }
-> :help
{ _, [ user, project, count ], _ } ->
{ user, project, count }
{ _, [ user, project ], _ } -> { user, project, @default_count }
{ _, [ _, project ], _ } -> { _, project, @default_count }
_ -> :help
end"
"
case parse do
{ [ help: true ], _, _ }
-> :help
{ _, [ user, project, count ], _ } ->
{ user, project, count }
{ _, [ user, project ], _ } -> { user, project, @default_count }
{ _, [ _, project ], _ } -> { _, project, @default_count }
_ -> :help
end")


(elixir-def-indentation-test complex-case-with-matches/2
(:tags '(indentation))
"
Expand Down Expand Up @@ -1668,16 +1644,14 @@ end
"case statement do
%{\"foo\" => \"foo\",
\"baz\" => \"baz\"} ->
:ok

_ ->
:ok
_ ->
:ok
end"
"case statement do
%{\"foo\" => \"foo\",
\"baz\" => \"baz\"} ->
:ok

_ ->
:ok
end")
Expand Down