Symbols with colon in the middle get wrong syntax highlighting
daveliepmann opened this issue · 1 comments
Symbols with colons in the middle (like a:b) get separate font faces before and after the colon.
Expected behavior
Symbols or bindings with a single colon : not at beginning or end should be recognized as a single symbol unit for the purpose of syntax highlighting. Specifically, it seems they should get font-lock-variable-name-face.
Per the Clojure reader reference docs for symbols:
Symbols beginning or ending with ':' are reserved by Clojure. A symbol can contain one or more non-repeating ':'s.
Actual behavior
A symbol with a colon (not at beginning or end) in the name-defining position gets the correct font-face (apparently font-lock-variable-name-face), but other instances get default for the pre-colon portion and clojure-keyword-face thereafter.
This makes every usage of the symbol or binding to get styled like a half-keyword, half-symbol.
Steps to reproduce the problem
(ns repl.clojure-mode-font-bug-colon)
(let [foo:bar 1]
foo:bar)
(def baz:qux 2)
baz:qux
(defn qqq:zzz [] 5)
qqq:zzzEnvironment & Version information
clojure-mode version
clojure-mode (version nil)
However, jumping to a clojure font-face definition gives me clojure-mode-20230626.715. (The clojure-mode invocation was broken in my previous spring 2022 version, too. I installed with package-list-packages from melpa.)
Emacs version
GNU Emacs 28.2 (build 1, aarch64-apple-darwin22.1.0, Carbon Version 169 AppKit 2299) of 2022-12-10
Operating system
macOS Ventura 13.4
the issue seems to be this snippet in clojure-font-lock-keywords:
(,(concat "\\(:\\{1,2\\}\\)\\(" clojure--keyword-sym-regexp "\\)")
(1 'clojure-keyword-face)
(2 'clojure-keyword-face))https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L1065