Skip to content

Commit 6717fe5

Browse files
committed
Merge pull request #332 from elixir-lang/fix-indentation-when-for-inside-def
Correct indent after using 'for' as function name
2 parents 83ff8fe + 253ccd4 commit 6717fe5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

elixir-smie.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@
455455
(cond
456456
((elixir-smie-last-line-end-with-block-operator-p)
457457
(smie-rule-parent elixir-smie-indent-basic))
458-
((smie-rule-prev-p "OP")
458+
((smie-rule-prev-p "OP" "def")
459459
(smie-rule-parent))))
460460
(`(:before . "do:")
461461
(cond

test/elixir-mode-indentation-test.el

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,25 @@ email: \"[email protected]\",
19181918
]
19191919
")
19201920

1921+
(elixir-def-indentation-test indent-block-after-for-inside-function-definition
1922+
(:tags '(indentation))
1923+
"
1924+
defmodule Test do
1925+
def for(domain) do
1926+
[_, tld] = String.split(domain, \".\", parts: 2)
1927+
Map.fetch(all, tld)
1928+
end
1929+
end
1930+
"
1931+
"
1932+
defmodule Test do
1933+
def for(domain) do
1934+
[_, tld] = String.split(domain, \".\", parts: 2)
1935+
Map.fetch(all, tld)
1936+
end
1937+
end
1938+
")
1939+
19211940
;; We don't want automatic whitespace cleanup here because of the significant
19221941
;; whitespace after `Record' above. By setting `whitespace-action' to nil,
19231942
;; `whitespace-mode' won't automatically clean up trailing whitespace (in my

0 commit comments

Comments
 (0)