Skip to content

Commit b25cea6

Browse files
committed
Merge pull request #333 from elixir-lang/fix-list-tuple-indentation
Fix indentation of second element inside list of tuples
2 parents 6717fe5 + 4829ada commit b25cea6

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

elixir-smie.el

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@
277277
"MATCH-STATEMENT-DELIMITER"
278278
(if (and (looking-at ".+,$")
279279
(not (> (nth 0 (syntax-ppss)) 0)))
280-
"COMMA"";")))
280+
"COMMA"
281+
";")))
281282
((looking-at elixir-smie--block-operator-regexp)
282283
(goto-char (match-end 0))
283284
"->")
@@ -337,6 +338,8 @@
337338
(pcase (cons kind token)
338339
(`(:list-intro . ";")
339340
-4)
341+
(`(:list-intro . nil)
342+
-4)
340343
(`(:elem . args)
341344
-4)
342345
(`(:before . "COMMA")
@@ -567,10 +570,6 @@
567570
((and (smie-rule-parent-p "OP")
568571
(smie-rule-hanging-p))
569572
(smie-rule-parent))
570-
((smie-rule-parent-p "[")
571-
(if (nth 0 smie--parent)
572-
(smie-rule-parent elixir-smie-indent-basic)
573-
(smie-rule-parent)))
574573
((smie-rule-parent-p "->")
575574
(if (save-excursion
576575
(move-end-of-line 1)
@@ -582,8 +581,7 @@
582581
(move-end-of-line 1)
583582
(looking-back elixir-smie--block-operator-regexp (- (point) 3) t))
584583
(smie-rule-parent (- elixir-smie-indent-basic))
585-
(smie-rule-parent)))
586-
(t (smie-rule-parent elixir-smie-indent-basic))))
584+
(smie-rule-parent)))))
587585
(`(:after . "{")
588586
(cond
589587
((smie-rule-hanging-p)

test/elixir-mode-indentation-test.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,11 @@ end
18741874
(elixir-def-indentation-test indent-maps-inside-list
18751875
(:tags '(indentation))
18761876
"
1877+
[{:earmark, \"~> 0.1\", only: :dev},
1878+
{:earmark, \"~> 0.1\", only: :dev},
1879+
{:ex_doc, \"~> 0.11\", only: :dev},
1880+
{:ex_doc, \"~> 0.11\", only: :dev}]
1881+
18771882
[
18781883
{1, 2, 3},
18791884
{4, 5, 6},
@@ -1896,6 +1901,11 @@ email: \"[email protected]\",
18961901
]
18971902
"
18981903
"
1904+
[{:earmark, \"~> 0.1\", only: :dev},
1905+
{:earmark, \"~> 0.1\", only: :dev},
1906+
{:ex_doc, \"~> 0.11\", only: :dev},
1907+
{:ex_doc, \"~> 0.11\", only: :dev}]
1908+
18991909
[
19001910
{1, 2, 3},
19011911
{4, 5, 6},

0 commit comments

Comments
 (0)