Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ankurdave/color-identifiers-mode
Emacs minor mode to highlight each source code identifier uniquely based on its name
https://github.com/ankurdave/color-identifiers-mode
Last synced: 3 days ago
JSON representation
Emacs minor mode to highlight each source code identifier uniquely based on its name
- Host: GitHub
- URL: https://github.com/ankurdave/color-identifiers-mode
- Owner: ankurdave
- Created: 2014-01-25T11:19:03.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T22:17:25.000Z (22 days ago)
- Last Synced: 2024-10-24T11:15:12.363Z (21 days ago)
- Language: Emacs Lisp
- Homepage:
- Size: 3.95 MB
- Stars: 307
- Watchers: 13
- Forks: 23
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Color Identifiers Mode
[![MELPA](http://melpa.org/packages/color-identifiers-mode-badge.svg)](http://melpa.org/#/color-identifiers-mode)Color Identifiers is a minor mode for Emacs that highlights each source code identifier uniquely based on its name. It is inspired by a [post by Evan Brooks](https://medium.com/p/3a6db2743a1e/).
Currently it supports Scala (scala-mode2), JavaScript (js-mode and js2-mode), Ruby, Python, Emacs Lisp, Clojure, C, C++, Rust, Java, and Go. You can add support for your favorite mode by modifying `color-identifiers:modes-alist` and optionally calling `color-identifiers:set-declaration-scan-fn`.
[Check out the demo.](http://youtu.be/g4qsiAo2aac)
![Screenshot of Color Identifiers Mode on Scala](https://raw.github.com/ankurdave/color-identifiers-mode/gh-pages/demo-static.png)
It picks colors adaptively to fit the theme:
![Different Themes](https://raw.github.com/ankurdave/color-identifiers-mode/gh-pages/themes.png)
Use `M-x color-identifiers:regenerate-colors` after a theme change.
## Installation
Color Identifiers is in [MELPA](https://github.com/milkypostman/melpa/pull/1416). First [set up MELPA](https://github.com/milkypostman/melpa#usage):```lisp
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-refresh-contents)
```Then install it:
```lisp
(package-install 'color-identifiers-mode)
```Finally, visit a supported file and type `M-x color-identifiers-mode`.
If you like it, enable it for all supported files by adding the following to your init file:
```lisp
(add-hook 'after-init-hook 'global-color-identifiers-mode)
```## Configuration
* Recoloring delay: the time before recoloring newly appeared identifiers is `2` seconds by default. To change it e.g. to `1` second add to your config `(setq color-identifiers:recoloring-delay 1)`
* Additional face-properties *(such as italic or bold)* can be added to the identifiers by modifying `color-identifiers:extra-face-attributes`. E.g. to make identifiers look bold use `(setq color-identifiers:extra-face-attributes '(:weight bold))`. But make sure not to change `:foreground` because it is the color of identifiers.
* To make the variables stand out, you can turn off highlighting for all other keywords in supported modes using a code like:
```lisp
(defun myfunc-color-identifiers-mode-hook ()
(let ((faces '(font-lock-comment-face font-lock-comment-delimiter-face font-lock-constant-face font-lock-type-face font-lock-function-name-face font-lock-variable-name-face font-lock-keyword-face font-lock-string-face font-lock-builtin-face font-lock-preprocessor-face font-lock-warning-face font-lock-doc-face font-lock-negation-char-face font-lock-regexp-grouping-construct font-lock-regexp-grouping-backslash)))
(dolist (face faces)
(face-remap-add-relative face '(:inherit default))))
(face-remap-add-relative 'font-lock-keyword-face '((:weight bold)))
(face-remap-add-relative 'font-lock-comment-face '((:slant italic)))
(face-remap-add-relative 'font-lock-builtin-face '((:weight bold)))
(face-remap-add-relative 'font-lock-preprocessor-face '((:weight bold)))
(face-remap-add-relative 'font-lock-function-name-face '((:slant italic)))
(face-remap-add-relative 'font-lock-string-face '((:slant italic)))
(face-remap-add-relative 'font-lock-constant-face '((:weight bold))))
(add-hook 'color-identifiers-mode-hook 'myfunc-color-identifiers-mode-hook)
```![Other Keywords Dimmed](https://raw.github.com/ankurdave/color-identifiers-mode/gh-pages/dim-other-keywords.png)
## Contributing
After having made changes to `color-identifiers-mode.el` you can test for regressions by running `ninja tests`. It checks lack of byte-compilation warnings and color-highlighting in various modes.
Improvements to the tests or the core mode are always welcome!