diff --git a/elixir-smie.el b/elixir-smie.el index 899912a3..172d9653 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -264,6 +264,10 @@ (defun elixir-smie-rules (kind token) (pcase (cons kind token) + (`(:list-intro . ";") + -4) + (`(:elem . args) + -4) (`(:before . "OP") (when (and (not (smie-rule-hanging-p)) (smie-rule-prev-p "OP")) @@ -282,12 +286,16 @@ (t (smie-rule-parent)))) (`(:before . "MATCH-STATEMENT-DELIMITER") (cond + ((smie-rule-parent-p "MATCH-STATEMENT-DELIMITER") + (smie-rule-parent)) ((and (not (smie-rule-sibling-p)) + (nth 2 smie--parent) (smie-rule-hanging-p)) (smie-rule-parent elixir-smie-indent-basic)) - ((smie-rule-parent-p "MATCH-STATEMENT-DELIMITER") - (smie-rule-parent)) - (t (smie-rule-parent elixir-smie-indent-basic)))) + ((and (not (smie-rule-sibling-p)) + (not (nth 2 smie--parent)) + (smie-rule-hanging-p)) + (smie-rule-parent)))) (`(:before . "fn") (smie-rule-parent)) (`(:before . "end") @@ -351,6 +359,7 @@ ((smie-rule-parent-p "if") (smie-rule-parent)) ((and (smie-rule-parent-p "(") + (boundp 'smie--parent) (save-excursion (goto-char (cadr smie--parent)) (smie-rule-hanging-p))) diff --git a/test/elixir-mode-indentation-test.el b/test/elixir-mode-indentation-test.el index f6ee2b1f..738c1396 100644 --- a/test/elixir-mode-indentation-test.el +++ b/test/elixir-mode-indentation-test.el @@ -1003,6 +1003,35 @@ defmodule X do end end") +(elixir-def-indentation-test indent-outside-block + (:tags '(indentation)) +" + 1 + 1 # => 2 + +sum = fn(a, b) -> +a + b + end + +sum.(1231, 3) + + a = 23 + a = a + +23 / 3" +" +1 + 1 # => 2 + +sum = fn(a, b) -> + a + b +end + +sum.(1231, 3) + +a = 23 +a = a + +23 / 3") + ;; We don't want automatic whitespace cleanup here because of the significant ;; whitespace after `Record' above. By setting `whitespace-action' to nil, ;; `whitespace-mode' won't automatically clean up trailing whitespace (in my