Skip to content

Instantly share code, notes, and snippets.

@unthingable
Last active December 31, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unthingable/8032086 to your computer and use it in GitHub Desktop.
Save unthingable/8032086 to your computer and use it in GitHub Desktop.
color-theme sensitive hl-line
;; (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