Skip to content

[[var]] wikilink font-lock rule collides with Datalog/Datomic relation-binding syntax #707

Description

@daveliepmann

Affected mode

clojure-mode

Expected behavior

Datalog vars in [[double square brackets]] get the same syntax highlighting as elsewhere.

Actual behavior

The [[var]] docstring-wikilink font-lock rule (added in #496) matches any
[[symbol]]-shaped text regardless of syntactic context — it isn't gated by
syntax-ppss to comments/docstrings/strings. This causes false-positive
highlighting in live Datalog/Datomic code, where [[var]] is legitimate
binding syntax (a relation binding, as opposed to [var] for a tuple binding
or [var ...] for a collection binding).

Version: clojure-mode 20250527.840 (current master exhibits the same
behavior as of 2026-09-23).

Suggested fix: gate the [[var]] (and backtick `code`) rules on
(nth 3 (syntax-ppss (match-beginning 0))) or (nth 4 ...) so they only
fire inside strings/comments, matching their intended use for docstrings.

Steps to reproduce

Based on Datomic docs:

(d/q '[:find ?track ?name ?duration
       :where
       [(q '[:find (min ?duration)
             :where [_ :track/duration ?duration]]
           $) [[?duration]]] ; <--------------------- this guy ain't right
       [?track :track/duration ?duration]
       [?track :track/name ?name]]
     db)

All five occurrences of ?duration are the same logic variable, but the one
inside [[?duration]] gets font-lock-constant-face (matched by the
wikilink rule at clojure-mode.el:1229-1232) while the other four get the
default face — inconsistent highlighting with no semantic basis.

Reproducible with emacs -Q

  • I've reproduced this with emacs -Q

clojure-mode version

20250527.840

Emacs version

GNU Emacs 30.2.50 (build 1, aarch64-apple-darwin24.6.0, Carbon Version 170 AppKit 2575.7) of 2026-03-09

Operating system

macOS Sequoia 15.8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions