[Emacs] Set highlight-indent-guides faces automatically

This commit is contained in:
Ivan Malison 2016-12-29 16:36:33 -08:00
parent 9c2ff311a1
commit 2ce30cfb89
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -1614,10 +1614,70 @@ https://github.com/alpaker/Fill-Column-Indicator/issues/21 for more details
(use-package highlight-indent-guides
:commands highlight-indent-guides-mode
:preface
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode)
(progn
(use-package hexrgb :demand t)
(defun imalison:change-hsv-value-by (delta)
(lambda (h s v)
(list h s (+ v delta))))
(defun imalison:build-safe-change-hsv-value (delta)
(lambda (h s v)
(imalison:safe-change-hsv-value
h s v delta)))
(defun imalison:new-hsv-value-safe (value)
(or (> value 1) (< value 0)))
(defun imalison:safe-change-hsv-value (h s v delta)
(let ((new-value (+ v delta)))
(if (imalison:new-hsv-value-safe new-value)
(let ((other-direction (+ v (* delta -2))))
(if (imalison:new-hsv-value-safe other-direction)
(user-error "delta %s is too large" delta)
(list h s other-direction)))
(list h s new-value))))
(defun imalison:modify-hsv (color fn)
(hexrgb-rgb-hex-to-rgb-hex
(apply 'hexrgb-hsv-to-hex (apply fn (hexrgb-hex-to-hsv color))) 2))
(defun imalison:modify-hsv-value-by (color delta)
(imalison:modify-hsv color (imalison:build-safe-change-hsv-value delta)))
(defvar imalison:hsv-value-delta .03)
(defun imalison:set-highlight-indent-guides-faces (&rest args)
(interactive)
(let ((bg-color (face-background 'default)))
(message "bg-color %s" bg-color)
(set-face-background 'highlight-indent-guides-odd-face
(imalison:modify-hsv
bg-color
(imalison:build-safe-change-hsv-value
(* -1 imalison:hsv-value-delta))))
(set-face-background 'highlight-indent-guides-even-face
(imalison:modify-hsv
bg-color
(imalison:build-safe-change-hsv-value
imalison:hsv-value-delta)))))
;; XXX: This hacks around the fact that (face-background 'default) is nil at
;; the time of load-theme
(defun imalison:set-highlight-indent-guides-faces-load-theme (&rest args)
(if (face-background 'default)
(imalison:set-highlight-indent-guides-faces)
(run-at-time "1 sec" nil 'imalison:set-highlight-indent-guides-faces-load-theme)))
(advice-add 'load-theme
:after 'imalison:set-highlight-indent-guides-faces-load-theme)
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode))
:config
(progn
(setq highlight-indent-guides-method 'fill)))
(setq lexical-binding t)
#+END_SRC
* Keybindings
** god-mode
@ -4120,9 +4180,11 @@ I have currently disabled key-chord because it may cause typing lag.
:commands helm-spotify)
#+END_SRC
** jabber
Disabled because it has its own version of hexrgb which might cause conflicts
#+BEGIN_SRC emacs-lisp
(use-package jabber
:commands jabber-connect
:disabled t
:config
(progn
(setq jabber-alert-presence-hooks nil)