Skip to content
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
11 changes: 8 additions & 3 deletions elixir-smie.el
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,11 @@
(`(:elem . args)
-4)
(`(:before . "OP")
(when (and (not (smie-rule-hanging-p))
(smie-rule-prev-p "OP"))
-2))
(cond ((and (not (smie-rule-hanging-p))
(smie-rule-prev-p "OP"))
-2)
((smie-rule-parent-p "def" "defp" "defmacro" "defmacrop")
(smie-rule-parent))))
(`(:after . "OP")
(cond
((smie-rule-sibling-p) nil)
Expand Down Expand Up @@ -383,6 +385,9 @@
;; IO.puts 'WORKED' <- Indent
((and (smie-rule-parent-p "for")
(not (smie-rule-hanging-p)))
(smie-rule-parent))
((and (smie-rule-parent-p "OP")
(not (smie-rule-hanging-p)))
(smie-rule-parent))))
(`(:before . "do")
(cond
Expand Down
34 changes: 29 additions & 5 deletions test/elixir-mode-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -942,16 +942,40 @@ end"
end")

(elixir-def-indentation-test indent-after-def-do-online/3
(:expected-result :failed :tags '(indentation))
"defmodule Foo do
def bar(baz, quun \\\\ nil)
def bar(baz, quun) when baz == quun, do: baz
def bar(baz, quun), do: quun
(:tags '(indentation))
" defmodule Foo do
def bar(baz, quun \\\\ nil)
def bar(baz, quun) when baz == quun, do: baz
def bar(baz, quun), do: quun

defp bar(baz, quun \\\\ nil)
defp bar(baz, quun) when baz == quun, do: baz
defp bar(baz, quun), do: quun

defmacro bar(baz, quun \\\\ nil)
defmacro bar(baz, quun) when baz == quun, do: baz
defmacro bar(baz, quun), do: quun

defmacrop bar(baz, quun \\\\ nil)
defmacrop bar(baz, quun) when baz == quun, do: baz
defmacrop bar(baz, quun), do: quun
end"
"defmodule Foo do
def bar(baz, quun \\\\ nil)
def bar(baz, quun) when baz == quun, do: baz
def bar(baz, quun), do: quun

defp bar(baz, quun \\\\ nil)
defp bar(baz, quun) when baz == quun, do: baz
defp bar(baz, quun), do: quun

defmacro bar(baz, quun \\\\ nil)
defmacro bar(baz, quun) when baz == quun, do: baz
defmacro bar(baz, quun), do: quun

defmacrop bar(baz, quun \\\\ nil)
defmacrop bar(baz, quun) when baz == quun, do: baz
defmacrop bar(baz, quun), do: quun
end")

(elixir-def-indentation-test indent-after-not-finished-one-line-def
Expand Down