clojure-mode
clojure-mode copied to clipboard
Symbols with ' in them are not font-locked correctly
A symbol with ' in it should be font-locked so that the whole symbol has the same color. I'm no expert on font-locking, nor on clojure-mode, but I quickly browsed the code, and this seems wrong:
(defconst clojure--sym-forbidden-rest-chars "][\";\'@\\^`~\(\)\{\}\\,\s\t\n\r"
since https://clojure.org/reference/reader says that '
is allowed in a symbol. I tried to change that but it didn't solve the problem below.
Steps to reproduce the problem
Type (defn test'fn [])
in clojure-mode and note the colors.
Expected behavior
All characters of test'fn
should be of the same color.
Actual behavior
The characters after and including '
are not of the expected color (they are white, my default text color).
clojure-mode version information
5.7.0-snapshot
I think the ' character is defined as a prefix character in the syntax table, so it goes beyond just font locking. So fixing it would probably take quite a bit of work, and there would probably be other broken behaviours (like forward-sexp or Isearch-symbol).
Wow that's surprising and odd at the same time.
Basically the problem stems for quoting symbols 'symbol
. It's rather hard to support this and allow quotes to appear anywhere in the symbol's name. I think allowing this was a major mistake in Clojure. Funny enough - officially this is not a valid symbol name, but it works and people use it. :-)
I think there is no harm in allowing '
to be a symbol for font-lock purpose. #290 is essentially un-fixable given current syntax table toolset in emacs, but this particular issue is easy.
Of course one would end up being surprised to see the doc completion for test
when point is on test'fn
but, well, at least it's highlighted properly.
@vspinu Yeah, you make a good point. Maybe we should just fix the font-locking. After all it's just tweaking a regular expression.
autogenerated with https://github.com/MalloZup/doghub: issue inactive since 450 days. Please update the issue or close it