[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6706bc2 218/271: Merge branch 'develop'
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 6706bc2 218/271: Merge branch 'develop' |
Date: |
Thu, 05 Feb 2015 18:31:22 +0000 |
branch: master
commit 6706bc2b0a1a58f5b8564d58f8501e27b8b4c234
Merge: 7b2a4c8 9a883e2
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Merge branch 'develop'
---
README.md | 37 +++++++++++++++++++++++++++++++++++++
context-coloring.el | 45 ++++++++++++++++++++++++++++++---------------
2 files changed, 67 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index 1216a68..b687f45 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,43 @@ make compile
(add-hook 'js-mode-hook 'context-coloring-mode)
```
+## Customizing
+
+You can adjust the colors to your liking using
+`context-coloring-set-colors`. The first argument is an alist of levels, and
the
+optional second argument is the new total number of levels. This plugin does
not
+figure out the total for you; you need to specify it if your number of colors
is
+different from the default (`7`).
+
+I like to take the colors from an existing theme and use those to create a
+rainbow that matches that theme. The end result is consistent, and usually
looks
+as good as the theme does. Here's an example for `tango`:
+
+```lisp
+;; ~/.emacs
+(load-theme 'tango)
+(require 'context-coloring)
+(defun jrh-context-coloring-tango ()
+ (interactive)
+ (context-coloring-set-colors
+ '((comment . "#5f615c")
+ (0 . "#2e3436") ; Globals.
+ (1 . "#346604")
+ (2 . "#204a87")
+ (3 . "#5c3566")
+ (4 . "#a40000")
+ (5 . "#b35000")
+ (6 . "#c4a000")
+ (7 . "#8ae234") ; "You're screwed" colors.
+ (8 . "#8cc4ff")
+ (9 . "#ad7fa8")
+ (10 . "#ef2929")
+ (11 . "#fcaf3e")
+ (12 . "#fce94f"))
+ 13))
+(jrh-context-coloring-tango)
+```
+
## Extending
To add support for a new language, write a "scopifier" for it, and add an entry
diff --git a/context-coloring.el b/context-coloring.el
index 477bc12..ef7164b 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -4,7 +4,7 @@
;; Author: Jackson Ray Hamilton <address@hidden>
;; Keywords: context coloring syntax highlighting
-;; Version: 2.0.1
+;; Version: 2.1.0
;; Package-Requires: ((emacs "24") (js2-mode "20141228"))
;; This program is free software; you can redistribute it and/or modify
@@ -189,22 +189,37 @@ Determines level at which to cycle through faces again."
;;; Face functions
+(defsubst context-coloring-face-symbol (level)
+ "Returns a symbol for a face with LEVEL."
+ (intern-soft (concat "context-coloring-level-" (number-to-string level)
"-face")))
+
+(defun context-coloring-set-colors (pairs &optional count)
+ "Set an alist of PAIRS for different levels' colors. Also sets
+`context-coloring-face-count' to COUNT, if specified."
+ (dolist (pair pairs)
+ (let ((level (car pair))
+ (color (cdr pair)))
+ (cond
+ ((eq level 'comment)
+ (setq level -1)))
+ (set-face-foreground (context-coloring-face-symbol level) color)))
+ (when count
+ (setq context-coloring-face-count count)))
+
(defsubst context-coloring-level-face (level)
"Return face-name for LEVEL as a string
\"context-coloring-level-LEVEL-face\".
-For example: \"context-coloring-level-1-face\"."
- (intern-soft
- (concat "context-coloring-level-"
- (number-to-string
- (or
- ;; Has a face directly mapping to it.
- (and (< level context-coloring-face-count)
- level)
- ;; After the number of available faces are used up, pretend the
0th
- ;; face doesn't exist.
- (+ 1
- (mod (- level 1)
- (- context-coloring-face-count 1)))))
- "-face")))
+For example: \"context-coloring-level-1-face\". Automatically
+wraps around to reuse faces when levels get too deep."
+ (context-coloring-face-symbol
+ (or
+ ;; Has a face directly mapping to it.
+ (and (< level context-coloring-face-count)
+ level)
+ ;; After the number of available faces are used up, pretend the 0th
+ ;; face doesn't exist.
+ (+ 1
+ (mod (- level 1)
+ (- context-coloring-face-count 1))))))
;;; Colorization utilities
- [elpa] master b325b91 250/271: Add current directory to load path for compilation., (continued)
- [elpa] master b325b91 250/271: Add current directory to load path for compilation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6755fdb 194/271: Pass test for key names., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 941070c 257/271: Add `make deps`., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6ce2b63 184/271: Bump required js2-mode version., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d1cb93b 241/271: Merge branch 'feature/dispatch' into develop, Jackson Ray Hamilton, 2015/02/05
- [elpa] master e05f044 191/271: Update js2-mode., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 04f6f73 185/271: Documentation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master ed2c33d 121/271: Merge branch 'feature/color-schemer' into develop, Jackson Ray Hamilton, 2015/02/05
- [elpa] master 196a6ed 209/271: Whoops., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 887f4c7 215/271: Merge branch 'master' into develop, Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6706bc2 218/271: Merge branch 'develop',
Jackson Ray Hamilton <=
- [elpa] master d813892 115/271: Add color-schemer utility., Jackson Ray Hamilton, 2015/02/05
- [elpa] master fadacd1 180/271: Add badge., Jackson Ray Hamilton, 2015/02/05
- [elpa] master cae3b72 240/271: Document new dispatch API., Jackson Ray Hamilton, 2015/02/05
- [elpa] master fedf885 269/271: Add note to readme about --version., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d1715b2 177/271: Remove .gitignore entry., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6e5e95a 211/271: Pass key-value pair test., Jackson Ray Hamilton, 2015/02/05
- [elpa] master bbebea1 253/271: Merge branch 'develop', Jackson Ray Hamilton, 2015/02/05
- [elpa] master 7059157 187/271: Add note on byte compilation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 8300976 244/271: Merge branch 'master' into develop, Jackson Ray Hamilton, 2015/02/05
- [elpa] master 9a883e2 217/271: Version 2.1.0., Jackson Ray Hamilton, 2015/02/05