Skip to content

Commit 031f280

Browse files
committed
Merge pull request #316 from BrunoBonacci/fix-font-locking
Fixed font-locking for def* with support of special chars
2 parents 82e75a0 + aabaa7d commit 031f280

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
* [#310](https://github.com/clojure-emacs/clojure-mode/issues/310) and [#311](https://github.com/clojure-emacs/clojure-mode/issues/311) Fix `clojure-expected-ns` in multi-source projects.
1414
* [#307](https://github.com/clojure-emacs/clojure-mode/issues/307): Don't highlight `handle` and `handler-case` as keywords.
1515

16+
### Bugs fixed
17+
18+
* Fix font-locking for def with special chars such as: `defn*`, `defspecial!`.
19+
1620
## 4.1.0 (20/06/2015)
1721

1822
### Changes

clojure-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ Called by `imenu--generic-function'."
380380
(2 font-lock-type-face nil t))
381381
;; Function definition (anything that starts with def and is not
382382
;; listed above)
383-
(,(concat "(\\(?:[a-z\.-]+/\\)?\\(def\[a-z\-\]*-?\\)"
383+
(,(concat "(\\(?:[a-z\.-]+/\\)?\\(def[^ \r\n\t]*\\)"
384384
;; Function declarations
385385
"\\>"
386386
;; Any whitespace

test/clojure-mode-font-lock-test.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ POS."
193193
(should (eq (clojure-test-face-at 2 5) 'font-lock-keyword-face))
194194
(should (eq (clojure-test-face-at 7 9) 'font-lock-function-name-face))))
195195

196+
(ert-deftest clojure-mode-syntax-table/custom-def-with-special-chars1 ()
197+
:tags '(fontification syntax-table)
198+
(clojure-test-with-temp-buffer "(defn* foo [x] x)"
199+
(should (eq (clojure-test-face-at 2 6) 'font-lock-keyword-face))
200+
(should (eq (clojure-test-face-at 8 10) 'font-lock-function-name-face))))
201+
202+
(ert-deftest clojure-mode-syntax-table/custom-def-with-special-chars2 ()
203+
:tags '(fontification syntax-table)
204+
(clojure-test-with-temp-buffer "(defsomething! foo [x] x)"
205+
(should (eq (clojure-test-face-at 2 14) 'font-lock-keyword-face))
206+
(should (eq (clojure-test-face-at 16 18) 'font-lock-function-name-face))))
207+
196208
(ert-deftest clojure-mode-syntax-table/lambda-params ()
197209
:tags '(fontification syntax-table)
198210
(clojure-test-with-temp-buffer "#(+ % %2 %3)"

0 commit comments

Comments
 (0)