color-identifiers-mode
color-identifiers-mode copied to clipboard
color-identifiers won't take affect automatically.
I put this in my init.el:
(add-hook 'after-init-hook 'global-color-identifiers-mode)
Restart my Emacs, open a C file, the color-identifiers-mode is already enabled(in mode-line), but the font-face doesn't change.
If I M-x color-identifiers:refresh once or M-x color-identifiers-mode twice (first to disable it then enable), the face will change.
Update:
Actually, after more than 5 seconds the face finally changes.
any thoughts here?
Actually, after more than 5 seconds the face finally changes.
There's a timeout before recoloring. It's done because Emacs doesn't support multi-threading (I hope may be these guys gonna solve it), and recoloring in the main thread on every little change would result in lags.
It's in seconds, the line
(run-with-idle-timer 5 t 'color-identifiers:refresh)))
I changed the 5 to 2 locally. I don't have time ATM, but you might want to make a PR with making it a global variable and modifying the README.
Emacs 26 supports cooperative multithreading.
So, what you want is achieved with changing a color-identifiers:timer variable to run immediately. E.g.:
(setq-default color-identifiers:timer (run-with-idle-timer 0 t 'color-identifiers:refresh))
Sans documenting that in README.md Idk what else can be done here.
Oh, yeah, ability to do that should work since this commit (I'm referring it in a PR even though it's merged, because it was accidentally squashed with another commit on merge).
Will be fixed by https://github.com/ankurdave/color-identifiers-mode/pull/87
After this PR is merged, you can add to your config a (setq color-identifiers:recoloring-delay 0) to make the recoloring take effect immediately.
I should note though that setting it to 0 may (or may not) slow down the mode, depending on how Emacs generates events to changes in buffer. I also think that newer Emacs versions are better in that regard. Anyway, I think that's a separate problem that deserves its own bugreport. As far as making the recoloring effect apply the change immediately, the PR adds an option for that (or the code snippet in this comment if you don't have the PR).
FTR: I opened a discussion to decrease the delay as well to reduce possible confusion https://github.com/ankurdave/color-identifiers-mode/pull/89