Skip to content

Commit afe7726

Browse files
committed
Merge pull request #334 from Malabarba/master
[Fix #331] Indentation in buffers without a final newline
2 parents b304afd + a86dae9 commit afe7726

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clojure-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ This function also returns nil meaning don't specify the indentation."
788788
((or (pred integerp) `(,method))
789789
(let ((pos -1))
790790
(condition-case nil
791-
(while (<= (point) indent-point)
791+
(while (and (<= (point) indent-point)
792+
(not (eobp)))
792793
(clojure-forward-logical-sexp 1)
793794
(cl-incf pos))
794795
;; If indent-point is _after_ the last sexp in the

test/clojure-mode-indentation-test.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
(require 'ert)
2929
(require 's)
3030

31+
(ert-deftest dont-hang-on-eob ()
32+
(with-temp-buffer
33+
(insert "(let [a b]")
34+
(clojure-mode)
35+
(goto-char (point-max))
36+
(should
37+
(with-timeout (2)
38+
(newline-and-indent)
39+
t))))
40+
3141
(defmacro check-indentation (description before after &optional var-bindings)
3242
"Declare an ert test for indentation behaviour.
3343
The test will check that the swift indentation command changes the buffer

0 commit comments

Comments
 (0)