Skip to content

Commit 3e5d793

Browse files
committed
Fix doctring indentation issue in #241
Added code to only apply the prefix if the current indent level is <= the default prefix spacing.
1 parent 31ea7ce commit 3e5d793

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

clojure-mode.el

+3-2
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,14 @@ point) to check."
624624
(put 'definline 'clojure-doc-string-elt 2)
625625
(put 'defprotocol 'clojure-doc-string-elt 2)
626626

627-
628627
(defun clojure-indent-line ()
629628
"Indent current line as Clojure code."
630629
(if (clojure-in-docstring-p)
631630
(save-excursion
632631
(beginning-of-line)
633-
(when (looking-at "^\\s-*")
632+
(when (and (looking-at "^\\s-*")
633+
(<= (string-width (match-string-no-properties 0))
634+
(string-width (clojure-docstring-fill-prefix))))
634635
(replace-match (clojure-docstring-fill-prefix))))
635636
(lisp-indent-line)))
636637

test/clojure-mode-indentation-test.el

+26
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,32 @@ values of customisable variables."
107107
(->>
108108
|expr)")
109109

110+
(check-indentation doc-strings-without-indent-specified
111+
"
112+
(defn some-fn
113+
|\"some doc string\""
114+
"
115+
(defn some-fn
116+
|\"some doc string\"")
117+
118+
(check-indentation doc-strings-with-correct-indent-specified
119+
"
120+
(defn some-fn
121+
|\"some doc string\""
122+
"
123+
(defn some-fn
124+
|\"some doc string\"")
125+
126+
(check-indentation doc-strings-with-additional-indent-specified
127+
"
128+
(defn some-fn
129+
|\"some doc string
130+
- some note\""
131+
"
132+
(defn some-fn
133+
|\"some doc string
134+
- some note\"")
135+
110136
(provide 'clojure-mode-indentation-test)
111137

112138
;; Local Variables:

0 commit comments

Comments
 (0)