Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### New features

* [#688](https://github.com/clojure-emacs/clojure-mode/issues/688): Add `clojure-discard-face` for `#_` reader discard forms, allowing them to be styled differently from comments. Inherits from `font-lock-comment-face` by default.

### Changes

* Update font-locking of built-in dynamic vars for Clojure 1.12.
Expand Down
10 changes: 9 additions & 1 deletion clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
"Face used to font-lock Clojure keywords (:something)."
:package-version '(clojure-mode . "3.0.0"))

(defface clojure-discard-face
'((t (:inherit font-lock-comment-face)))
"Face used to font-lock forms discarded by Clojure's #_ reader macro."
:package-version '(clojure-mode . "5.22.0"))

(defface clojure-character-face
'((t (:inherit font-lock-string-face)))
"Face used to font-lock Clojure character literals."
Expand Down Expand Up @@ -1153,7 +1158,10 @@ any number of matches of `clojure--sym-forbidden-rest-chars'."))
(1 nil))

;; #_ and (comment ...) macros.
(clojure--search-comment-macro 1 font-lock-comment-face t)
(clojure--search-comment-macro
1 (if (eq (char-after (match-beginning 0)) ?#)
'clojure-discard-face font-lock-comment-face)
t)
;; Highlight `code` marks, just like `elisp'.
(,(rx "`" (group-n 1 (optional "#'")
(+ (or (syntax symbol) (syntax word)))) "`")
Expand Down
10 changes: 5 additions & 5 deletions test/clojure-mode-font-lock-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,19 @@ DESCRIPTION is the description of the spec."
(1 2 nil))

("#_#_"
(3 2 font-lock-comment-face))
(3 2 clojure-discard-face))

("#_ #_"
(1 3 nil))

("#_ #_"
(4 2 font-lock-comment-face))
(4 2 clojure-discard-face))

("#_ \n;; some crap\n (lala 0101\n lao\n\n 0 0i)"
(1 2 nil))

("#_ \n;; some crap\n (lala 0101\n lao\n\n 0 0i)"
(5 41 font-lock-comment-face))
(5 41 clojure-discard-face))

("#_#_ \n;; some crap\n (lala 0101\n lao\n\n 0 0i)\n;; more crap\n (foobar tnseriao)"
(1 4 nil))
Expand All @@ -159,10 +159,10 @@ DESCRIPTION is the description of the spec."
(1 5 nil))

("#_#_ \n;; some crap\n (lala 0101\n lao\n\n 0 0i)\n;; more crap\n (foobar tnseriao)"
(7 75 font-lock-comment-face))
(7 75 clojure-discard-face))

("#_ #_ \n;; some crap\n (lala 0101\n lao\n\n 0 0i)\n;; more crap\n (foobar tnseriao)"
(8 75 font-lock-comment-face)))
(8 75 clojure-discard-face)))

(when-fontifying-it "should handle namespace declarations"
("(ns .validns)"
Expand Down