clojure-mode
clojure-mode copied to clipboard
Only namespaces containing prefixes are fontlocked in the ns form

This happens most often in prefix vectors but applies everywhere
It's pretty hard to deal with this using regular expressions. Fixes welcome, but it's low on my todo list.
Bear in mind that single-segment namespaces are strongly advised-against as they cause issues with AOT and JVM interop.
@cichli That's debatable https://github.com/bbatsov/clojure-style-guide/pull/100
Ah, was not aware that it did not actually cause problems in practice (although I seem to remember reading that how packageless classes are dealt with is JVM-dependent?).
It definitely can cause serious, hard-to-debug, issues in clojurescript though:
Compiler support for single segment namespaces has always been spotty and there's no intention to improve it. There are fundamental semantic issues - for example if you have a DOM element with a CSS id and you haven't supplied a namespace but you goog.require one with that name it will return the DOM element. Good luck debugging that. Single segment namespaces are nearly alway representative of a problem waiting to manifest. If you want to use them then you can suppress the warning in your build options.
You might want to mention this in the style guide issue. :-)
On 11 March 2015 at 19:06, Michael Griffiths [email protected] wrote:
Ah, was not aware that it did not actually cause problems in practice (although I seem to remember reading that how packageless classes are dealt with is JVM-dependent?).
It definitely can cause serious, hard-to-debug, issues in clojurescript though:
Compiler support for single segment namespaces has always been spotty and there's no intention to improve it. There are fundamental semantic issues - for example if you have a DOM element with a CSS id and you haven't supplied a namespace but you goog.require one with that name it will return the DOM element. Good luck debugging that. Single segment namespaces are nearly alway representative of a problem waiting to manifest. If you want to use them then you can suppress the warning in your build options.
— Reply to this email directly or view it on GitHub https://github.com/clojure-emacs/clojure-mode/issues/280#issuecomment-78307848 .
Best Regards, Bozhidar Batsov
http://www.batsov.com
Is there any alternative font-locking mechanism for emacs that can be used when the context is hard to capture with a regex?
You can use anything for the font-locking, but I've rarely seen modes that aren't 100% regexp based. The use of a parser or a live process obviously adds extra deps and people generally prefer simpler solutions.
I guess I should point out that there are no single-segment namespaces in the OP.
There is no support for syntax highlighting of libspecs in clojure-mode yet, other than highlighting of stuff following this form: foo.bar.baz.
In the image in OP one can argue whether the prefix, refactor-nrepl-core, should be highlighted or if only the namespaces below this prefix should be highlighted (analyzer, find-symbol etc). My preference would be to highlight both the prefix and the suffixes.