Skip to content

Symbols with colon in the middle get wrong syntax highlighting #653

Closed
@daveliepmann

Description

@daveliepmann

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.

Screenshot 2023-07-07 at 01 44 43

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:zzz

Environment & 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions