Skip to content

Commit ab04a23

Browse files
committed
Emit semicolon in case of trailing whitespace.
Lines ending like `\s+$` should not impact indentation of subsequent lines. Instead, the trailing whitespace should be tokenized as if it didn't exist.
1 parent ec6a97c commit ab04a23

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

elixir-smie.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
">=" "<" ">" "&&" "||" "<>" "++" "--" "//"
8181
"/>" "=~" "|>" "->")))
8282

83+
(defvar elixir-smie--spaces-til-eol-regexp
84+
(rx (and (1+ space) eol))
85+
"Regex representing one or more whitespace characters concluding with eol.")
86+
8387
(defvar elixir-smie-indent-basic 2)
8488

8589
(defmacro elixir-smie-debug (message &rest format-args)
@@ -94,6 +98,11 @@
9498

9599
(defun elixir-smie-forward-token ()
96100
(cond
101+
;; If there is nothing but whitespace between the last token and eol, emit
102+
;; a semicolon.
103+
((looking-at elixir-smie--spaces-til-eol-regexp)
104+
(goto-char (match-end 0))
105+
";")
97106
((and (looking-at "[\n#]") (elixir-smie--implicit-semi-p))
98107
(if (eolp) (forward-char 1) (forward-comment 1))
99108
";")

0 commit comments

Comments
 (0)