hylang / hy-mode

Hy mode for Emacs
GNU General Public License v3.0
191 stars 47 forks source link

FR: syntax highlighting that recognized discard prefix #_ as comment? #66

Closed bennyandresen closed 6 years ago

bennyandresen commented 6 years ago

Feature Request:

The clojure-mode does it. I checked clojure-mode.el a bit but font-locking makes no sense to me.

Would be nice to have. :-)

ekaschalk commented 6 years ago

How does Clojure do it? Is only the immediate form highlighted as a comment? And does this highlighting span multiple lines?

bennyandresen commented 6 years ago

Multiple lines (the whole form), see here:

before after

ekaschalk commented 6 years ago

Ok, sure I can add this. The multiple lines part makes it a bit more involved than the other font-locks.

ekaschalk commented 6 years ago

Are indentation rules preserved inside the commented form? Or does it behave like a string, ie. inserting a newline within the captured from will indent at the margin?

I have the former working already. The latter needs requires another approach than font-locks.

ekaschalk commented 6 years ago

03322cf34d94ba99aa86f8b3fa213c81a5c185b7 #_ now supported, I checked Clojure and indeed its the former, and I see why.

bennyandresen commented 6 years ago

Doesn't work for me:

(defn foo-bar [baz]
  (setv foo (-> (.get baz QUUX)
                (. value)
                first))
  (or foo 0))

Only (. value) receives the comment font-lock. Other defns don't receive any font-lock at all.

ekaschalk commented 6 years ago

Any form with other syntax highlighting broke it for the form, moving this keyword to the top fixes this.

However, the constant 0 is also highlighted and still overwrites the comment tag.

So almost solid, have to understand why constants are special.

ekaschalk commented 6 years ago

I believe #_ should work now for everything: e84eb689b93feca77713c0f3e3303e52772a32f1

Constants are actually handled by highlight-numbers-mode which was causing issues before.

bennyandresen commented 6 years ago

I can confirm that this works! Thanks @ekaschalk!