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."
784
784
(pcase method
785
785
((or (pred integerp) `(, method ))
786
786
(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)))
793
796
(cond
794
797
((= pos (1+ method))
795
798
(+ lisp-body-indent containing-form-column))
Original file line number Diff line number Diff line change @@ -211,16 +211,18 @@ values of customisable variables."
211
211
212
212
213
213
; ;; 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 ."
216
216
(declare (indent 1 ))
217
217
`(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))))))))
224
226
225
227
(def-full-indent-test closing-paren
226
228
" (ns ca
@@ -266,6 +268,17 @@ values of customisable variables."
266
268
" #?@ (:clj []
267
269
:cljs [])" )
268
270
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
+
269
282
270
283
; ;; Misc
271
284
You can’t perform that action at this time.
0 commit comments