Skip to content

Fix second element of forms starting with 'def' being highlighted as function name #632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2022
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
7 changes: 3 additions & 4 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -878,10 +878,9 @@ any number of matches of `clojure--sym-forbidden-rest-chars'."))
"\\(?:#?^\\(?:{[^}]*}\\|\\sw+\\)[ \r\n\t]*\\)*"
"\\(\\sw+\\)?")
(2 font-lock-type-face nil t))
;; Function definition (anything that starts with def and is not
;; listed above)
(,(concat "(\\(?:" clojure--sym-regexp "/\\)?"
"\\(def[^ \r\n\t]*\\)"
;; Function definition
(,(concat "(\\(?:clojure.core/\\)?"
"\\(defn\\)"
;; Function declarations
"\\>"
;; Any whitespace
Expand Down
22 changes: 11 additions & 11 deletions test/clojure-mode-font-lock-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -776,17 +776,17 @@ DESCRIPTION is the description of the spec."
(6 42 clojure-keyword-face)))

(when-fontifying-it "should handle namespaced defs"
("(_c4/defn bar [] nil)"
(2 4 font-lock-type-face)
(5 5 nil)
(6 9 font-lock-keyword-face)
(11 13 font-lock-function-name-face))

("(clo/defrecord foo nil)"
(2 4 font-lock-type-face)
(5 5 nil)
(6 14 font-lock-keyword-face)
(16 18 font-lock-function-name-face))
("(clojure.core/defn bar [] nil)"
(2 13 font-lock-type-face)
(14 14 nil)
(15 18 font-lock-keyword-face)
(20 22 font-lock-function-name-face))

("(clojure.core/defrecord foo nil)"
(2 13 font-lock-type-face)
(14 14 nil)
(15 23 font-lock-keyword-face)
(25 27 font-lock-type-face))

("(s/def ::keyword)"
(2 2 font-lock-type-face)
Expand Down