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

Making ns-qualified keywords not have font-lock-type-face

Open vemv opened this issue 7 years ago • 7 comments

Given a ns-qualified keyword such as:

::kws.grid/column-settings

I'd like only clojure-keyword-face to be applied to it. But also font-lock-type-face is partially applied to it:

How it looks like

image

How it is parsed

#("::kws.grid/column-settings" 0 6 (fontified t face (clojure-keyword-face)) 6 10 (fontified t face (font-lock-type-face clojure-keyword-face)) 10 11 (fontified t face (default clojure-keyword-face)) 11 25 (fontified t face (clojure-keyword-face)) 25 26 (fontified t font-lock-multiline t face (clojure-keyword-face)))

The problematic bit seems to be (font-lock-type-face clojure-keyword-face).

I'm not sure if this is a feature. To me it looks buggy, because only grid gets the grey coloring. But in the example grid does not have a special meaning.


Using clojure-mode latest/pristine, no fork

vemv avatar Jan 20 '18 16:01 vemv

In case it helps, this is the culprit:

      ;; foo/ Foo/ @Foo/ /FooBar
      (,(concat "\\(?:\\<:?\\|\\.\\)@?\\(" clojure--sym-regexp "\\)\\(/\\)")
       (1 font-lock-type-face) (2 'default))

vemv avatar Jan 20 '18 17:01 vemv

@Bost I think your ns font-locking changes addressed this, right?

bbatsov avatar Mar 28 '18 02:03 bbatsov

@Bost I think your ns font-locking changes addressed this, right?

Yes it does. (@vemv Bozo references to the 14d4221.) A bit of an explanation - the ::kws.grid/column-settings is not a valid keyword. I assume we want to take a look at :kws.grid/column-settings, then:

user> ::kws.grid/column-settings
RuntimeException Invalid token: ::kws.grid/column-settings  clojure.lang.Util.runtimeException (Util.java:221)
user> :kws.grid/column-settings
:kws.grid/column-settings
user> (namespace :kws.grid/column-settings) ;; namespace font-locked as font-lock-type-face
kws.grid
user> (name :kws.grid/column-settings) ;; keyword names font-locked as clojure-keyword-face
column-settings
user>

And here is how is looks like: image

So to answer:

(font-lock-type-face clojure-keyword-face) I'm not sure if this is a feature. To me it looks buggy. grid does not have a special meaning.

Yea you were looking at a buggy feature implementation, now hopefully fixed. Please get the 14d4221 and have a look again.

Bost avatar Mar 28 '18 11:03 Bost

::kws.grid/column-settings is not a valid keyword

For the record: it is - if you :require x as kws.grid, then ::kws.grid/column-settings will become a valid keyword in the current ns/context.

Will checkout CIDER @ latest asap.

Thanks!

vemv avatar Mar 28 '18 13:03 vemv

What??? Egh...

user> (require '[clojure.core :as kws.grid])
nil
user> ::kws.grid/fn
:clojure.core/fn
user> ::kws.grid/ufo
:clojure.core/ufo
user> (namespace ::kws.grid/ufo)   ;; I wonder how many folks get confused over this?
clojure.core
user> (name ::kws.grid/ufo)
ufo
user> (name :kws.grid/ufo)
ufo
user> (namespace :kws.grid/ufo)
kws.grid
user> 

egh... really. I think it would be a good idea to indicate it with some different font-face. @bbatsov?

Bost avatar Mar 28 '18 14:03 Bost

(namespace ::kws.grid/ufo) might be bit of an unfair example ;p

One normally aliases using close terms (e.g clojure -> clj)

Thus, (namespace ::clj.cr/fn) returning :clojure.core/fn seems more defensible!

So a different font-fact may be overkill.

vemv avatar Mar 28 '18 14:03 vemv

autogenerated with https://github.com/MalloZup/doghub: issue inactive since 450 days. Please update the issue or close it

MalloZup avatar Aug 05 '19 21:08 MalloZup