2019-10-09 13:13:56 +02:00
|
|
|
;;; colorscheme.el --- Syntax highlight and friends -*- lexical-binding: t -*-
|
2020-09-01 11:17:43 +02:00
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
2020-09-01 11:17:43 +02:00
|
|
|
;; Version: 0.0.1
|
|
|
|
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
|
|
|
|
;; Package-Requires: ((emacs "24.3"))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; TODO: Clarify this.
|
|
|
|
;; Since I have my own definition of "theme", which couples wallpaper, font,
|
|
|
|
;; with Emacs's traditional notion of the word "theme", I'm choosing to use
|
|
|
|
;; "colorscheme" to refer to *just* the notion of syntax highlight etc.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Dependencies
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(require 'cycle)
|
2020-09-01 17:26:39 +02:00
|
|
|
(require '>)
|
2020-09-02 16:23:46 +02:00
|
|
|
(require 'cl-lib)
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Library
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defcustom colorscheme-whitelist
|
|
|
|
(cycle-from-list
|
2020-01-17 11:24:45 +01:00
|
|
|
(->> (custom-available-themes)
|
2020-09-01 11:17:43 +02:00
|
|
|
(list-map #'symbol-name)
|
2020-09-01 17:26:39 +02:00
|
|
|
(list-filter (>-> (s-starts-with? "doom-")))
|
2020-09-01 11:17:43 +02:00
|
|
|
(list-map #'intern)))
|
2019-10-09 13:13:56 +02:00
|
|
|
"The whitelist of colorschemes through which to cycle.")
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun colorscheme-current ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Return the currently enabled colorscheme."
|
2020-09-01 11:17:43 +02:00
|
|
|
(cycle-current colorscheme-whitelist))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun colorscheme-disable-all ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Disable all currently enabled colorschemes."
|
|
|
|
(interactive)
|
|
|
|
(->> custom-enabled-themes
|
2020-09-01 11:17:43 +02:00
|
|
|
(list-map #'disable-theme)))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun colorscheme-set (theme)
|
2019-10-09 13:13:56 +02:00
|
|
|
"Call `load-theme' with `THEME', ensuring that the line numbers are bright.
|
|
|
|
There is no hook that I'm aware of to handle this more elegantly."
|
2020-01-17 11:21:59 +01:00
|
|
|
(load-theme theme t)
|
2020-08-31 18:05:31 +02:00
|
|
|
(prelude-set-line-number-color "#da5468"))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun colorscheme-whitelist-set (colorscheme)
|
|
|
|
"Focus the COLORSCHEME in the `colorscheme-whitelist' cycle."
|
|
|
|
(cycle-focus (lambda (x) (equal x colorscheme)) colorscheme-whitelist)
|
|
|
|
(colorscheme-set (colorscheme-current)))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun colorscheme-ivy-select ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Load a colorscheme using ivy."
|
|
|
|
(interactive)
|
2020-09-01 11:17:43 +02:00
|
|
|
(let ((theme (ivy-read "Theme: " (cycle-to-list colorscheme-whitelist))))
|
|
|
|
(colorscheme-disable-all)
|
|
|
|
(colorscheme-set (intern theme))))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(cl-defun colorscheme-cycle (&key forward?)
|
2019-10-09 13:13:56 +02:00
|
|
|
"Cycle next if `FORWARD?' is non-nil.
|
|
|
|
Cycle prev otherwise."
|
2020-09-01 11:17:43 +02:00
|
|
|
(disable-theme (cycle-current colorscheme-whitelist))
|
2019-10-09 13:13:56 +02:00
|
|
|
(let ((theme (if forward?
|
2020-09-01 11:17:43 +02:00
|
|
|
(cycle-next colorscheme-whitelist)
|
|
|
|
(cycle-prev colorscheme-whitelist))))
|
|
|
|
(colorscheme-set theme)
|
2020-09-01 00:28:47 +02:00
|
|
|
(message (s-concat "Active theme: " (symbol-to-string theme)))))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun colorscheme-next ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Disable the currently active theme and load the next theme."
|
|
|
|
(interactive)
|
2020-09-01 11:17:43 +02:00
|
|
|
(colorscheme-cycle :forward? t))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun colorscheme-prev ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Disable the currently active theme and load the previous theme."
|
|
|
|
(interactive)
|
2020-09-01 11:17:43 +02:00
|
|
|
(colorscheme-cycle :forward? nil))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
(provide 'colorscheme)
|
|
|
|
;;; colorscheme.el ends here
|