From 8652558a7cfed7fe2c1f06dea3d38ad7c64089fc Mon Sep 17 00:00:00 2001 From: Vadim Rodionov Date: Sat, 3 Sep 2022 14:59:02 +0600 Subject: [PATCH] Make function definition regexp only look for 'clojure.core/defn' forms --- clojure-mode.el | 7 +++---- test/clojure-mode-font-lock-test.el | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/clojure-mode.el b/clojure-mode.el index 30f6baca..5586852b 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -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 diff --git a/test/clojure-mode-font-lock-test.el b/test/clojure-mode-font-lock-test.el index cd4f21fc..4a7877b1 100644 --- a/test/clojure-mode-font-lock-test.el +++ b/test/clojure-mode-font-lock-test.el @@ -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)