diff --git a/elixir-smie.el b/elixir-smie.el index 8935399c..3d8d6acd 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -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) @@ -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 diff --git a/test/elixir-mode-indentation-test.el b/test/elixir-mode-indentation-test.el index cb1f6e4b..81deb78e 100644 --- a/test/elixir-mode-indentation-test.el +++ b/test/elixir-mode-indentation-test.el @@ -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