Skip to content

Commit 4815653

Browse files
committed
Merge pull request #289 from sandhu/master
Fix doctring indentation issue in #241
2 parents 75e34d9 + 3e5d793 commit 4815653

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
@@ -622,13 +622,14 @@ point) to check."
622622
(put 'definline 'clojure-doc-string-elt 2)
623623
(put 'defprotocol 'clojure-doc-string-elt 2)
624624

625-
626625
(defun clojure-indent-line ()
627626
"Indent current line as Clojure code."
628627
(if (clojure-in-docstring-p)
629628
(save-excursion
630629
(beginning-of-line)
631-
(when (looking-at "^\\s-*")
630+
(when (and (looking-at "^\\s-*")
631+
(<= (string-width (match-string-no-properties 0))
632+
(string-width (clojure-docstring-fill-prefix))))
632633
(replace-match (clojure-docstring-fill-prefix))))
633634
(lisp-indent-line)))
634635

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)