Skip to content

Commit 39a9ee3

Browse files
committed
[Fix #304] Indentation of forms with metadata specs
We were indenting like this (ns ^:doc app.core (:gen-class)) Now we indent like this (ns ^:doc app.core (:gen-class))
1 parent d3f12ab commit 39a9ee3

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

clojure-mode.el

+13-11
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ This function also returns nil meaning don't specify the indentation."
683683
(progn (forward-sexp 1) (point))))
684684
(open-paren (elt state 1))
685685
(method nil)
686+
(forward-sexp-function #'clojure-forward-logical-sexp)
686687
(function-tail (car
687688
(reverse
688689
(split-string (substring-no-properties function) "/")))))
@@ -1076,17 +1077,18 @@ Returns a list pair, e.g. (\"defn\" \"abc\") or (\"deftest\" \"some-test\")."
10761077
This will skip over sexps that don't represent objects, so that ^hints and
10771078
#reader.macros are considered part of the following sexp."
10781079
(interactive "p")
1079-
(if (< n 0)
1080-
(clojure-backward-logical-sexp (- n))
1081-
(while (> n 0)
1082-
;; Non-logical sexps.
1083-
(while (progn (forward-sexp 1)
1084-
(forward-sexp -1)
1085-
(looking-at-p "\\^\\|#[[:alpha:]]"))
1086-
(forward-sexp 1))
1087-
;; The actual sexp
1088-
(forward-sexp 1)
1089-
(setq n (1- n)))))
1080+
(let ((forward-sexp-function nil))
1081+
(if (< n 0)
1082+
(clojure-backward-logical-sexp (- n))
1083+
(while (> n 0)
1084+
;; Non-logical sexps.
1085+
(while (progn (forward-sexp 1)
1086+
(forward-sexp -1)
1087+
(looking-at-p "\\^\\|#[[:alpha:]]"))
1088+
(forward-sexp 1))
1089+
;; The actual sexp
1090+
(forward-sexp 1)
1091+
(setq n (1- n))))))
10901092

10911093
(defun clojure-backward-logical-sexp (&optional n)
10921094
"Move backward N logical sexps.

test/clojure-mode-indentation-test.el

+8
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ values of customisable variables."
153153
(ala/bala top
154154
|one)")
155155

156+
(check-indentation form-with-metadata
157+
"
158+
(ns ^:doc app.core
159+
|(:gen-class))"
160+
"
161+
(ns ^:doc app.core
162+
|(:gen-class))")
163+
156164

157165
(provide 'clojure-mode-indentation-test)
158166

0 commit comments

Comments
 (0)