File tree Expand file tree Collapse file tree 2 files changed +30
-14
lines changed Expand file tree Collapse file tree 2 files changed +30
-14
lines changed Original file line number Diff line number Diff line change @@ -784,12 +784,15 @@ This function also returns nil meaning don't specify the indentation."
784784 (pcase method
785785 ((or (pred integerp) `(, method ))
786786 (let ((pos -1 ))
787- ; ; `forward-sexp' will error if indent-point is after
788- ; ; the last sexp in the current sexp.
789- (ignore-errors
790- (while (<= (point ) indent-point)
791- (clojure-forward-logical-sexp 1 )
792- (cl-incf pos)))
787+ (condition-case nil
788+ (while (<= (point ) indent-point)
789+ (clojure-forward-logical-sexp 1 )
790+ (cl-incf pos))
791+ ; ; If indent-point is _after_ the last sexp in the
792+ ; ; current sexp, we detect that by catching the
793+ ; ; `scan-error' . In that case, we should return the
794+ ; ; indentation as if there were an extra sexp at point.
795+ (scan-error (cl-incf pos)))
793796 (cond
794797 ((= pos (1+ method))
795798 (+ lisp-body-indent containing-form-column))
Original file line number Diff line number Diff line change @@ -211,16 +211,18 @@ values of customisable variables."
211211
212212
213213; ;; Backtracking indent
214- (defmacro def-full-indent-test (name form )
215- " Verify that FORM corresponds to a properly indented sexp ."
214+ (defmacro def-full-indent-test (name &rest forms )
215+ " Verify that all FORMs correspond to a properly indented sexps ."
216216 (declare (indent 1 ))
217217 `(ert-deftest ,(intern (format " test-backtracking-%s " name)) ()
218- (with-temp-buffer
219- (clojure-mode)
220- (insert " \n " ,(replace-regexp-in-string " \n +" " \n " form))
221- (indent-region (point-min ) (point-max ))
222- (should (equal (buffer-string )
223- ,(concat " \n " form))))))
218+ (progn
219+ ,@(dolist (form forms)
220+ `(with-temp-buffer
221+ (clojure-mode)
222+ (insert " \n " ,(replace-regexp-in-string " \n +" " \n " form))
223+ (indent-region (point-min ) (point-max ))
224+ (should (equal (buffer-string )
225+ ,(concat " \n " form))))))))
224226
225227(def-full-indent-test closing-paren
226228 " (ns ca
@@ -266,6 +268,17 @@ values of customisable variables."
266268 " #?@ (:clj []
267269 :cljs [])" )
268270
271+ (def-full-indent-test empty-close-paren
272+ " (let [x]
273+ )"
274+
275+ " (ns ok
276+ )"
277+
278+ " (ns ^{:zen :dikar}
279+ ok
280+ )" )
281+
269282
270283; ;; Misc
271284
You can’t perform that action at this time.
0 commit comments