Skip to content

Instantly share code, notes, and snippets.

@phelrine
Created June 28, 2011 22:34
Show Gist options
  • Save phelrine/1052417 to your computer and use it in GitHub Desktop.
Save phelrine/1052417 to your computer and use it in GitHub Desktop.
rainbow highlight line
;;; (require 'rainbow-hl-line)
;;; (rainbow-hl-line-mode 1)
(defgroup rainbow-hl-line nil "rainbow-hl-line custom group")
(defcustom rainbow-hl-line-color-list
(list "red4" "orange4" "yellow4" "green4" "blue4" "magenta4")
"color list"
:type '(repeat string)
:group 'rainbow-hl-line)
(defun rainbow-hl-line-highlight ()
(set-face-background 'hl-line
(nth (% (line-number-at-pos)
(length rainbow-hl-line-color-list))
rainbow-hl-line-color-list)))
(define-minor-mode rainbow-hl-line-mode
"rainbow highlight line mode"
:global t
:group 'rainbow-hl-line
(if rainbow-hl-line-mode
(progn
(global-hl-line-mode 1)
(add-hook 'post-command-hook #'rainbow-hl-line-highlight))
(global-hl-line-mode -1)
(remove-hook 'post-command-hook #'rainbow-hl-line-highlight)))
(provide 'rainbow-hl-line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment