Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color identifiers mode #2930

Closed
wants to merge 1 commit into from
Closed

Conversation

punassuming
Copy link
Contributor

Add color identifiers mode, toggled by SPC t C i.

@mbertheau
Copy link
Contributor

Hmm, how does this play with rainbow-identifiers, which is on the same key binding?

:evil-leader "tCi")

@punassuming
Copy link
Contributor Author

Oops, I noticed it free but I didnt load all packages before doing so. I will revise the bindings.

@syl20bnr
Copy link
Owner

syl20bnr commented Sep 9, 2015

What are the differences with https://github.com/Fanael/rainbow-identifiers (in the colors layer) ?

@punassuming
Copy link
Contributor Author

rainbow-identifiers seems to color all unique text in the buffer with different colors. color-identifiers-mode on the other hand, recognizes variable in the source and colors only the variables in the source. I should add this to the color package though. Will do that now...

:defer t
:init
(progn
(spacemacs|diminish color-identifiers-mode "C " "C ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first C has got to be Ⓒ (compare

(spacemacs|diminish aggressive-indent-mode "" " I"))))
)

@mbertheau
Copy link
Contributor

I think we should form an opinion which identifier coloring package is better and include only one by default. @Ralesi's description above sounds like color-identifiers-mode is more sensible than rainbow-identifiers.

To that end I tried this PR locally, but toggling it with tCI doesn't change identifier color from their bland gray. color-identifiers mode is active. Does somebody know how to debug this?

@punassuming
Copy link
Contributor Author

@mbertheau, this mode is relatively unobtrusive, it will not change the text for common patterns, unless it recognizes it as a variable. Look at a let or setq construct and see if you can see the colors change then.

Here is an example from micro-state
20150911_112231_emacs exe

@syl20bnr
Copy link
Owner

@Ralesi can you make a screenshot with rainbow identifier as well so we can compare ?

I see an advantage of color-indentifiers, it tries to be smart about the choice of colors, I have to test with different themes to see how it looks. In rainbow-identifiers the saturation and lightness have to be adjusted for each theme (a couple are preconfigured in the layer).

@punassuming
Copy link
Contributor Author

Here is the same section with rainbow-identifiers. Pretty much everything is a color, which also makes it difficult to determine what is a variable and what is a macro / defun.
20150911_130011_emacs exe

@mbertheau
Copy link
Contributor

@Ralesi: I see it now, thanks :)

I'll try with color-identifiers for a while and report back.

@mbertheau
Copy link
Contributor

@Ralesi Can you add something such that color-identifiers can be toggled on globally for all new buffers?

@Kethku
Copy link
Contributor

Kethku commented Sep 11, 2015

(add-hook 'prog-mode-hook (lambda () (color-identifiers-mode t)))
😉

@kritzcreek
Copy link
Contributor

Does this only work for elisp or understands color-identifiers a notion of "variables" in other languages too?

@punassuming
Copy link
Contributor Author

@kritzcreek, currently, it supports Scala (scala-mode2), JavaScript (js-mode and js2-mode), Ruby, Python, Emacs Lisp, Clojure, C, C++, and Java out of the box.

@kritzcreek
Copy link
Contributor

@Ralesi so does it still provide colored identifiers for other languages? The docs don't say anything about that. And that would be quite the regression from rainbow-identifiers.

@Kethku
Copy link
Contributor

Kethku commented Sep 12, 2015

We could have both packages and use color identifiers for the supported languages and then rainbow identifiers for the rest. Best of both worlds

Sent from my Windows Phone


From: Christoph Hegemannmailto:notifications@github.com
Sent: ‎9/‎12/‎2015 12:09 PM
To: syl20bnr/spacemacsmailto:spacemacs@noreply.github.com
Cc: Keith Simmonsmailto:keith@the-simmons.net
Subject: Re: [spacemacs] Color identifiers mode (#2930)

@ralesihttps://github.com/ralesi so does it still provide colored identifiers for other languages? The docs don't say anything about that. And that would be quite the regression from rainbow-identifiers.


Reply to this email directly or view it on GitHubhttps://github.com//pull/2930#issuecomment-139810205.

@punassuming
Copy link
Contributor Author

We can also modify color-identifiers:modes-alist to support the missing modes.

@syl20bnr
Copy link
Owner

syl20bnr commented Jun 4, 2016

Thank you ! 👍
I made the choice between color-identifiers and rainbow-identifiers available via the new layer variable colors-colorize-identifiers which can take the value variables (color-identifiers) all (rainbow-identifiers) or nil.
The variable colors-enable-rainbow-identifiers has been removed.
Also the key bindings have been adjusted:
SPC t C a for rainbow-identifiers (colorize all)
SPC t C v for color-identifiers (colorize variables only)
Those key bindings are always available (ie, both packages are always installed).
related commit: dde9eef

Cherry-picked into develop branch, you can safely delete your branch.

@syl20bnr syl20bnr closed this Jun 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants