clojure-mode icon indicating copy to clipboard operation
clojure-mode copied to clipboard

Only namespaces containing prefixes are fontlocked in the ns form

Open expez opened this issue 10 years ago • 8 comments

Imgur

This happens most often in prefix vectors but applies everywhere

expez avatar Mar 11 '15 11:03 expez

It's pretty hard to deal with this using regular expressions. Fixes welcome, but it's low on my todo list.

bbatsov avatar Mar 11 '15 11:03 bbatsov

Bear in mind that single-segment namespaces are strongly advised-against as they cause issues with AOT and JVM interop.

cichli avatar Mar 11 '15 11:03 cichli

@cichli That's debatable https://github.com/bbatsov/clojure-style-guide/pull/100

bbatsov avatar Mar 11 '15 16:03 bbatsov

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.

cichli avatar Mar 11 '15 17:03 cichli

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

bbatsov avatar Mar 11 '15 17:03 bbatsov

Is there any alternative font-locking mechanism for emacs that can be used when the context is hard to capture with a regex?

expez avatar Mar 12 '15 06:03 expez

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.

bbatsov avatar Mar 12 '15 07:03 bbatsov

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.

expez avatar Jun 11 '15 19:06 expez