Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct indentation outside of blocks #196

Merged
merged 1 commit into from
May 25, 2015
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
15 changes: 12 additions & 3 deletions elixir-smie.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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")
Expand Down Expand Up @@ -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)))
Expand Down
29 changes: 29 additions & 0 deletions test/elixir-mode-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down