Skip to content

Commit 49b6a48

Browse files
author
Carlos Requena López
committed
[Fix #445] More accurate font locking for strings in def forms
- def forms can now have docstrings and strings properly font-locked - they will not be incorrectly indented added tests as well
1 parent 2cf589c commit 49b6a48

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

clojure-mode-font-lock-test.el

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,34 @@ POS."
718718
(should (eq (clojure-test-face-at 6 8 "(def foo 10)")
719719
'font-lock-variable-name-face)))
720720

721+
(ert-deftest clojure-mode-syntax-table/variable-def-string ()
722+
:tags '(fontification syntax-table)
723+
(should (eq (clojure-test-face-at 10 16 "(def foo \"hello\")")
724+
'font-lock-string-face))
725+
(should (eq (clojure-test-face-at 10 16 "(def foo \"hello\" )")
726+
'font-lock-string-face))
727+
(should (eq (clojure-test-face-at 13 19 "(def foo \n \"hello\")")
728+
'font-lock-string-face))
729+
(should (eq (clojure-test-face-at 13 19 "(def foo \n \"hello\"\n)")
730+
'font-lock-string-face)))
731+
732+
(ert-deftest clojure-mode-syntax-table/variable-def-string-with-docstring ()
733+
:tags '(fontification syntax-table)
734+
(should (eq (clojure-test-face-at 10 16 "(def foo \"usage\" \"hello\")")
735+
'font-lock-doc-face))
736+
(should (eq (clojure-test-face-at 18 24 "(def foo \"usage\" \"hello\")")
737+
'font-lock-string-face))
738+
(should (eq (clojure-test-face-at 18 24 "(def foo \"usage\" \"hello\" )")
739+
'font-lock-string-face))
740+
(should (eq (clojure-test-face-at 21 27 "(def foo \"usage\" \n \"hello\")")
741+
'font-lock-string-face))
742+
(should (eq (clojure-test-face-at 13 19 "(def foo \n \"usage\" \"hello\")")
743+
'font-lock-doc-face))
744+
(should (eq (clojure-test-face-at 13 19 "(def foo \n \"usage\" \n \"hello\")")
745+
'font-lock-doc-face))
746+
(should (eq (clojure-test-face-at 24 30 "(def foo \n \"usage\" \n \"hello\")")
747+
'font-lock-string-face)))
748+
721749
(ert-deftest clojure-mode-syntax-table/type-def ()
722750
:tags '(fontification syntax-table)
723751
(clojure-test-with-temp-buffer "(deftype Foo)"

clojure-mode-indentation-test.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ values of customisable variables."
6868
(search-forward "|")
6969
(delete-char -1)
7070
(clojure-mode)
71+
(font-lock-ensure)
7172
(indent-according-to-mode)
7273

7374
(should (equal expected-state (buffer-string)))
@@ -118,6 +119,10 @@ values of customisable variables."
118119
(->>
119120
|expr)")
120121

122+
(check-indentation no-indent-for-def-string
123+
"(def foo \"hello|\")"
124+
"(def foo \"hello|\")")
125+
121126
(check-indentation doc-strings-without-indent-specified
122127
"
123128
(defn some-fn

0 commit comments

Comments
 (0)