Def highlighting is out of control #377
Comments
I was pretty sure we had fixed this, at least for the word default. ... |
It's not possible to fix this without enumerating proper Proper defs can occur inside let forms, so highlighting top forms only is not a real fix. One way to go about it is to highlight only |
Maybe we should remove this from clojure-mode and add the smarter behavior to CIDER, where we actually have the ability to understand the code? |
I could swear we had fixed this ages ago, something related to not highlighting the symbol |
I'm coming across this requiring a lib as |
I've been bitten by this too. The problem is the following line inside
See https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L777 for context. I've changed that to:
-- so only the calls we know for sure about are highlighted. I think it's much better to under-highlight than to over-highlight; the editor being "too smart" is simply annoying. We should also probably have the stuff as we have for indentation, i.e.
While that's not done, I propose to go for the fixed set of highlighted def*s. Let me know if you want a pull request for that. Also, we can add a defcustom for the list of symbols to highlight, so it'll actually be trivial to add other symbols to the list. |
Sounds like a reasonable approach. I like it. It's clear that we can't have a one-regexp fits all solution here.
Actually CIDER will highlight things differently even now based on their type - macros are font-locked as keywords, built-in as built-ins, function names as functions and so on. |
Good! So do you want a pull request (defcustom list of symbols + the change of regex) or would you rather hack on it yourself?
Right - but what I had in mind is some kind of |
PR would be great. The work on nREPL is eating all my spare time these days.
Yeah, I guess that makes sense if you want to override the defaults. It should also be relatively simple to do. |
Before changing this at clojure-mode side, could we have :style/defform metadata implemented first? Before breaking long term behavior we should have a workaround. I often use Some suggestion from above are milder solutions than an explicit list of keywords:
Let's also consider the exclusion metadata |
I love the I think we should be conservative because you can always opt-in your own code (though not library code) but you can't opt-out with a |
I am not sure I understand. You can modify other library var's metadata from your code. Or you could PR to that library and popularize :style/not-a-defform, or you could fix it on emacs side by adding keywords to the exclusion list. There are some possibilities. In any case, for the completeness sake both |
I think I'm running into a related issue. My problem is that if I have a Removing the |
Expected behavior
Proper syntax highlighting
Actual behavior
Steps to reproduce the problem
Write a form containing a word starting with
def
anywhere, e.g.(defface 'angry-face)
I get that the intent was to highlight
defresource
etc the same way asdefn
but this really isn't working as intended. All calls to functions like(default-user-settings)
are highlighted like a def now, no matter where in the source they appear.The text was updated successfully, but these errors were encountered: