Skip to content

Commit ed636c9

Browse files
@(dynamic)variable shouldn't break fontlock
Currently `foo/some-var` will fontlock `foo`, but if this item is something that can be dereffed and you type `@foo/some-var`, `foo` is no longer font-locked. Similarly: `*dynamic-var*` is font locked, but `@` breaks the regex. In this change the `@` sign isn't font locked, but the var that follows it is. Conflicts: clojure-mode.el Add tests for dynamic-var and ns/refer fontlock
1 parent 4e8d632 commit ed636c9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

clojure-mode.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ Called by `imenu--generic-function'."
467467
t)
468468
"\\>")
469469
0 font-lock-builtin-face)
470-
;; Dynamic variables - *something*
471-
("\\<\\*[a-z-]*\\*\\>" 0 font-lock-variable-name-face)
470+
;; Dynamic variables - *something* or @*something*
471+
("\\<@?\\(\\*[a-z-]*\\*\\)\\>" 1 font-lock-variable-name-face)
472472
;; Global constants - nil, true, false
473473
(,(concat
474474
"\\<"
@@ -492,8 +492,8 @@ Called by `imenu--generic-function'."
492492
("\\(?:\\<\\|\\.\\|/\\|#?^\\)\\([A-Z][a-zA-Z0-9_]*[a-zA-Z0-9$_]+\\.?\\>\\)" 1 font-lock-type-face)
493493
;; foo.bar.baz
494494
("\\<^?\\([a-z][a-z0-9_-]+\\.\\([a-z][a-z0-9_-]*\\.?\\)+\\)" 1 font-lock-type-face)
495-
;; foo/ Foo/
496-
("\\<\\([a-zA-Z][a-z0-9_-]*\\)/" 1 font-lock-type-face)
495+
;; foo/ Foo/ @Foo/
496+
("\\<@?\\([a-zA-Z][a-z0-9_-]*\\)/" 1 font-lock-type-face)
497497
;; fooBar
498498
("\\(?:\\<\\|/\\)\\([a-z]+[A-Z]+[a-zA-Z0-9$]*\\>\\)" 1 'clojure-interop-method-face)
499499
;; Highlight grouping constructs in regular expressions

test/clojure-mode-test.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ POS."
202202
(should (eq (clojure-test-face-at 1 5 "#+clj x") 'font-lock-preprocessor-face))
203203
(should (eq (clojure-test-face-at 1 6 "#+cljs x") 'font-lock-preprocessor-face)))
204204

205+
(ert-deftest clojure-mode-syntax-table/refer-ns ()
206+
:tags '(fontification syntax-table)
207+
(should (eq (clojure-test-face-at 1 3 "foo/var") 'font-lock-type-face))
208+
(should (eq (clojure-test-face-at 2 4 "@foo/var") 'font-lock-type-face)))
209+
210+
(ert-deftest clojure-mode-syntax-table/dynamic-var ()
211+
:tags '(fontification syntax-table)
212+
(should (eq (clojure-test-face-at 1 10 "*some-var*") 'font-lock-variable-name-face))
213+
(should (eq (clojure-test-face-at 2 11 "@*some-var*") 'font-lock-variable-name-face)))
214+
205215
(provide 'clojure-mode-test)
206216

207217
;; Local Variables:

0 commit comments

Comments
 (0)