Last active
December 31, 2015 19:09
-
-
Save unthingable/8032086 to your computer and use it in GitHub Desktop.
color-theme sensitive hl-line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; (set-face-background hl-line-face "medium purple") | |
;; fix hl-line color dynamically: | |
(require 'hexrgb) | |
(defun my-fix-hl-line-color () | |
"Adjust hl-line color relative to current color theme" | |
(interactive) | |
(let* | |
((color (face-attribute 'default :background)) | |
(value (hexrgb-value color)) | |
(threshold 0.32) | |
(scale 0.9) | |
(separation 0.06) | |
(new-value | |
(+ threshold | |
(* scale | |
(+ (- value threshold) | |
(if (< value threshold) 0.15 (- 0.0))))))) | |
(set-face-background | |
hl-line-face | |
(hexrgb-increment-value color (- new-value value))) | |
(message "%S %S" value new-value))) | |
(add-hook 'after-init-hook 'my-fix-hl-line-color) | |
(if (package-installed-p 'color-theme) | |
(defadvice color-theme-install-at-point (after fix-hl-line activate) | |
(my-fix-hl-line-color))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment