From 2ce30cfb89a03d90da7d26e061acbca6590c8f6a Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 29 Dec 2016 16:36:33 -0800 Subject: [PATCH] [Emacs] Set highlight-indent-guides faces automatically --- dotfiles/emacs.d/README.org | 64 ++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 30a2b544..5dbee9f8 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -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)