2016-09-12 14:06:43 +00:00
|
|
|
;;; doom-themes.el --- a pack of themes inspired by Atom One
|
|
|
|
;;
|
|
|
|
;; Copyright (C) 2016 Henrik Lissner
|
|
|
|
;;
|
|
|
|
;; Author: Henrik Lissner <http://github/hlissner>
|
|
|
|
;; Maintainer: Henrik Lissner <henrik@lissner.net>
|
|
|
|
;; Created: May 22, 2016
|
2017-06-06 17:25:36 +00:00
|
|
|
;; Modified: Jun 06, 2017
|
|
|
|
;; Version: 2.0.0
|
2017-01-11 09:40:29 +00:00
|
|
|
;; Keywords: dark blue atom one theme neotree nlinum icons
|
2016-09-12 14:24:50 +00:00
|
|
|
;; Homepage: https://github.com/hlissner/emacs-doom-theme
|
2017-01-11 01:03:29 +00:00
|
|
|
;; Package-Requires: ((emacs "24.4") (all-the-icons "1.0.0") (cl-lib "0.5"))
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
2017-05-16 08:17:33 +00:00
|
|
|
;; DOOM Themes is an opinionated UI plugin and pack of themes extracted from my
|
2017-06-06 14:56:43 +00:00
|
|
|
;; [emacs.d], inspired by some of my favorite color themes including:
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
2017-06-06 14:56:43 +00:00
|
|
|
;; [X] `doom-one': inspired by [Atom]'s One Dark themes
|
|
|
|
;; [-] `doom-one-light': light version of doom-one
|
|
|
|
;; [X] `doom-vibrant': a more vibrant version of `doom-one`
|
|
|
|
;; [X] `doom-molokai': based on Textmate's monokai
|
|
|
|
;; [-] `doom-nova': adapted from [Nova] (thanks to [bigardone])
|
|
|
|
;; [ ] `doom-x': reads your colors from ~/.Xresources
|
|
|
|
;; [-] `doom-tomorrow-night' / `doom-tomorrow-day': by [Chris Kempson][tomorrow]
|
|
|
|
;; [ ] `doom-spacegrey': [I'm sure you've heard of it][spacegrey]
|
|
|
|
;; [ ] `doom-mono-dark' / `doom-mono-light': a minimalistic, monochromatic theme
|
|
|
|
;; [ ] `doom-tron': based on Tron Legacy from [daylerees' themes][daylerees]
|
|
|
|
;; [ ] `doom-peacock': based on Peacock from [daylerees' themes][daylerees]
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
2017-06-06 14:56:43 +00:00
|
|
|
;; ## Install
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
2017-06-06 14:56:43 +00:00
|
|
|
;; `M-x package-install RET doom-themes`
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
2017-06-06 14:56:43 +00:00
|
|
|
;; A comprehensive configuration example:
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
|
|
|
;; (require 'doom-themes)
|
2017-06-06 14:56:43 +00:00
|
|
|
;;
|
|
|
|
;; ;; Global settings (defaults)
|
2017-05-17 10:47:26 +00:00
|
|
|
;; (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
|
|
|
|
;; doom-themes-enable-italic t) ; if nil, italics is universally disabled
|
2017-05-16 08:17:33 +00:00
|
|
|
;;
|
2017-06-06 14:56:43 +00:00
|
|
|
;; ;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each
|
|
|
|
;; ;; theme may have their own settings.
|
|
|
|
;; (load-theme 'doom-one t)
|
2017-05-16 08:17:33 +00:00
|
|
|
;;
|
2017-06-06 14:56:43 +00:00
|
|
|
;; ;; Enable flashing mode-line on errors
|
|
|
|
;; (doom-themes-visual-bell-config)
|
2017-05-16 08:17:33 +00:00
|
|
|
;;
|
|
|
|
;; ;; Enable custom neotree theme
|
|
|
|
;; (doom-themes-neotree-config) ; all-the-icons fonts must be installed!
|
|
|
|
;;
|
2016-09-12 14:06:43 +00:00
|
|
|
;;; Code:
|
|
|
|
|
2017-01-11 01:03:29 +00:00
|
|
|
(require 'cl-lib)
|
2016-09-19 15:40:51 +00:00
|
|
|
|
|
|
|
(defgroup doom-themes nil
|
2017-05-17 10:46:03 +00:00
|
|
|
"Options for doom-themes."
|
2016-09-19 15:40:51 +00:00
|
|
|
:group 'faces)
|
|
|
|
|
2017-06-03 11:00:12 +00:00
|
|
|
(defface doom-modeline-error '((t (:inherit error :inverse-video t)))
|
|
|
|
"Face to use for the mode-line when `doom-themes-visual-bell-config' is used."
|
|
|
|
:group 'doom-themes)
|
|
|
|
|
2016-09-19 15:40:51 +00:00
|
|
|
;;
|
2017-05-17 10:47:26 +00:00
|
|
|
(defcustom doom-themes-enable-bold t
|
2017-05-01 18:19:44 +00:00
|
|
|
"If nil, bold will be disabled across all faces."
|
2016-09-19 15:40:51 +00:00
|
|
|
:group 'doom-themes
|
|
|
|
:type 'boolean)
|
|
|
|
|
2017-05-17 10:47:26 +00:00
|
|
|
(defcustom doom-themes-enable-italic t
|
2017-05-01 18:19:44 +00:00
|
|
|
"If nil, italics will be disabled across all faces."
|
2016-09-19 15:40:51 +00:00
|
|
|
:group 'doom-themes
|
|
|
|
:type 'boolean)
|
|
|
|
|
2017-05-17 10:51:56 +00:00
|
|
|
(define-obsolete-variable-alias 'doom-enable-italic 'doom-themes-enable-italic "1.2.9")
|
|
|
|
(define-obsolete-variable-alias 'doom-enable-bold 'doom-themes-enable-bold "1.2.9")
|
2017-05-17 10:47:26 +00:00
|
|
|
|
2017-06-03 09:30:52 +00:00
|
|
|
(defvar doom-themes--colors nil)
|
|
|
|
(defvar doom-themes--inhibit-warning nil)
|
|
|
|
(defvar doom-themes--bell-p nil)
|
2017-05-01 08:06:22 +00:00
|
|
|
|
2016-09-19 15:40:51 +00:00
|
|
|
|
|
|
|
;; Color helper functions
|
|
|
|
;; Shamelessly *borrowed* from solarized
|
|
|
|
(defun doom-name-to-rgb (color &optional frame)
|
2017-05-01 18:19:44 +00:00
|
|
|
"Retrieves the hexidecimal string repesented the named COLOR (e.g. \"red\")
|
|
|
|
for FRAME (defaults to the current frame)."
|
2016-09-19 15:40:51 +00:00
|
|
|
(mapcar (lambda (x) (/ x (float (car (color-values "#ffffff")))))
|
|
|
|
(color-values color frame)))
|
|
|
|
|
|
|
|
(defun doom-blend (color1 color2 alpha)
|
2017-05-01 18:19:44 +00:00
|
|
|
"Blend two colors (hexidecimal strings) together by a coefficient ALPHA (a
|
|
|
|
float between 0 and 1)"
|
2017-05-02 05:10:52 +00:00
|
|
|
(when (and color1 color2)
|
2017-06-03 00:41:21 +00:00
|
|
|
(cond ((or (listp color1) (listp color2))
|
|
|
|
(mapcar (lambda (x)
|
|
|
|
(let ((c2 (if (listp color2) (pop color2) color2)))
|
|
|
|
(when c2 (doom-blend x c2 alpha))))
|
|
|
|
color1))
|
|
|
|
|
|
|
|
((and (string-prefix-p "#" color1) (string-prefix-p "#" color2))
|
|
|
|
(apply (lambda (r g b) (format "#%02x%02x%02x" (* r 255) (* g 255) (* b 255)))
|
|
|
|
(cl-mapcar (lambda (it other) (+ (* alpha it) (* other (- 1 alpha))))
|
|
|
|
(doom-name-to-rgb color1)
|
|
|
|
(doom-name-to-rgb color2))))
|
|
|
|
|
|
|
|
(t color1))))
|
2016-09-19 15:40:51 +00:00
|
|
|
|
|
|
|
(defun doom-darken (color alpha)
|
2017-05-01 18:19:44 +00:00
|
|
|
"Darken a COLOR (a hexidecimal string) by a coefficient ALPHA (a float between
|
|
|
|
0 and 1)."
|
2017-06-03 00:41:21 +00:00
|
|
|
(if (listp color)
|
|
|
|
(mapcar (lambda (c) (doom-darken c alpha)) color)
|
|
|
|
(doom-blend color "#000000" (- 1 alpha))))
|
2016-09-19 15:40:51 +00:00
|
|
|
|
|
|
|
(defun doom-lighten (color alpha)
|
2017-05-01 18:19:44 +00:00
|
|
|
"Brighten a COLOR (a hexidecimal string) by a coefficient ALPHA (a float
|
|
|
|
between 0 and 1)."
|
2017-06-03 00:41:21 +00:00
|
|
|
(if (listp color)
|
|
|
|
(mapcar (lambda (c) (doom-lighten c alpha)) color)
|
|
|
|
(doom-blend color "#FFFFFF" (- 1 alpha))))
|
2016-09-19 15:40:51 +00:00
|
|
|
|
2017-06-03 00:41:21 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom-color (name &optional type)
|
|
|
|
"Retrieve a specific color named NAME (a symbol) from the current theme."
|
|
|
|
(let ((colors (cdr-safe (assq name doom-themes--colors))))
|
|
|
|
(and colors
|
2017-06-06 16:54:42 +00:00
|
|
|
(cond ((listp colors)
|
|
|
|
(let ((i (or (plist-get '(256 1 16 2 8 3) type) 0)))
|
|
|
|
(if (> i (1- (length colors)))
|
|
|
|
(car (last colors))
|
|
|
|
(nth i colors))))
|
|
|
|
(t colors)))))
|
2016-09-19 15:40:51 +00:00
|
|
|
|
2017-05-04 09:11:18 +00:00
|
|
|
(defmacro def-doom-theme (name docstring defs &optional extra-faces extra-vars)
|
2017-06-03 00:41:21 +00:00
|
|
|
"Define a DOOM theme, named NAME (a symbol)."
|
2017-05-01 08:06:22 +00:00
|
|
|
(declare (doc-string 2))
|
2017-06-03 00:41:21 +00:00
|
|
|
(require 'doom-themes-common)
|
|
|
|
(let ((doom-themes--colors defs))
|
2017-05-02 05:11:54 +00:00
|
|
|
`(let* ((gui (or (display-graphic-p) (= (tty-display-color-cells) 16777216)))
|
2017-05-17 10:47:26 +00:00
|
|
|
(bold doom-themes-enable-bold)
|
|
|
|
(italic doom-themes-enable-italic)
|
2017-05-02 05:11:54 +00:00
|
|
|
,@defs)
|
2017-06-03 00:41:21 +00:00
|
|
|
(setq doom-themes--colors (mapcar (lambda (d)
|
|
|
|
(cons (car d)
|
|
|
|
(eval
|
|
|
|
(if (eq (cadr d) 'quote)
|
|
|
|
(caddr d)
|
|
|
|
(cadr d)))))
|
|
|
|
',defs))
|
2017-05-02 05:11:54 +00:00
|
|
|
(deftheme ,name ,docstring)
|
2017-06-03 00:41:21 +00:00
|
|
|
(custom-theme-set-faces ',name ,@(doom-themes-common-faces extra-faces))
|
2017-06-03 19:41:30 +00:00
|
|
|
(custom-theme-set-variables ',name ,@(doom-themes-common-variables extra-vars))
|
2017-05-02 05:11:54 +00:00
|
|
|
(provide-theme ',name))))
|
2017-05-01 08:06:22 +00:00
|
|
|
|
2017-06-03 00:41:21 +00:00
|
|
|
(defun doom-themes-common-faces (&optional extra-faces)
|
|
|
|
"Return an alist of face definitions for `custom-theme-set-faces'.
|
|
|
|
|
|
|
|
Faces in EXTRA-FACES override the default faces."
|
|
|
|
(mapcar
|
|
|
|
#'doom-themes--build-face
|
|
|
|
(cl-remove-duplicates (append doom-themes-common-faces extra-faces)
|
|
|
|
:key #'car)))
|
|
|
|
|
|
|
|
(defun doom-themes-common-variables (&optional extra-vars)
|
|
|
|
"Return an alist of variable definitions for `custom-theme-set-variables'.
|
|
|
|
|
|
|
|
Variables in EXTRA-VARS override the default ones."
|
|
|
|
(mapcar
|
|
|
|
#'doom-themes--build-var
|
|
|
|
(cl-remove-duplicates (append doom-themes-common-vars extra-vars)
|
|
|
|
:key #'car)))
|
2017-05-01 08:06:22 +00:00
|
|
|
|
2017-05-04 09:11:18 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom-themes-neotree-config ()
|
2017-05-17 10:46:03 +00:00
|
|
|
"Install doom-themes' neotree configuration.
|
|
|
|
|
|
|
|
Includes an Atom-esque icon theme and highlighting based on filetype."
|
2017-06-03 00:41:21 +00:00
|
|
|
(let ((doom-themes--inhibit-warning t))
|
|
|
|
(require 'doom-themes-neotree)))
|
2017-05-04 09:11:18 +00:00
|
|
|
|
2017-02-22 22:11:50 +00:00
|
|
|
;;;###autoload
|
2017-06-03 00:41:21 +00:00
|
|
|
(defun doom-themes-visual-bell-config ()
|
|
|
|
"Enable flashing the mode-line on error."
|
|
|
|
(setq ring-bell-function #'doom-themes-visual-bell-fn
|
|
|
|
visible-bell t))
|
2017-05-16 09:14:29 +00:00
|
|
|
|
2017-06-03 00:41:21 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom-themes-visual-bell-fn ()
|
|
|
|
"Blink the mode-line red briefly. Set `ring-bell-function' to this to use it."
|
|
|
|
(unless doom-themes--bell-p
|
|
|
|
(let ((old-remap (copy-alist face-remapping-alist)))
|
|
|
|
(setq doom-themes--bell-p t)
|
|
|
|
(setq face-remapping-alist
|
|
|
|
(append (delete (assq 'mode-line face-remapping-alist) face-remapping-alist)
|
|
|
|
'((mode-line doom-modeline-error))))
|
|
|
|
(force-mode-line-update)
|
|
|
|
(run-with-timer 0.15 nil
|
|
|
|
(lambda (remap buf)
|
|
|
|
(with-current-buffer buf
|
2017-06-03 09:31:52 +00:00
|
|
|
(when (assq 'mode-line face-remapping-alist)
|
|
|
|
(setq face-remapping-alist remap
|
|
|
|
doom-themes--bell-p nil))
|
2017-06-03 00:41:21 +00:00
|
|
|
(force-mode-line-update)))
|
|
|
|
old-remap
|
|
|
|
(current-buffer)))))
|
2017-02-22 22:11:50 +00:00
|
|
|
|
2016-09-19 15:40:51 +00:00
|
|
|
;;;###autoload
|
|
|
|
(when (and (boundp 'custom-theme-load-path) load-file-name)
|
2017-06-03 00:41:21 +00:00
|
|
|
(let* ((base (file-name-directory load-file-name))
|
|
|
|
(dir (expand-file-name "themes/" base)))
|
|
|
|
(add-to-list 'custom-theme-load-path
|
|
|
|
(or (and (file-directory-p dir) dir)
|
|
|
|
base))))
|
2016-09-19 15:40:51 +00:00
|
|
|
|
2017-06-06 12:11:19 +00:00
|
|
|
|
|
|
|
;; DEPRECATED FUNCTIONS
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom-brighten-minibuffer ()
|
|
|
|
"Does nothing. `doom-brighten-minibuffer' has been moved to the `solaire-mode'
|
|
|
|
package as `solaire-mode-in-minibuffer'. This function is deprecated."
|
|
|
|
(message "doom-themes: doom-brighten-minibuffer has moved to the solaire-mode package"))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(define-minor-mode doom-buffer-mode
|
|
|
|
"Does nothing. `doom-buffer-mode' has been moved to the `solaire-mode'
|
|
|
|
package. This function is deprecated."
|
|
|
|
:lighter "" ; should be obvious it's on
|
|
|
|
:init-value nil
|
|
|
|
(message "doom-themes: doom-buffer-mode has moved to the solaire-mode package"))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom-buffer-mode-maybe ()
|
|
|
|
"Does nothing. `doom-buffer-mode' has been moved to the `solaire-mode'
|
|
|
|
package. This function is deprecated."
|
|
|
|
(doom-buffer-mode +1))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom-themes-nlinum-config ()
|
|
|
|
"Does nothing. This functionality has been moved to the `nlinum-hl' package.
|
|
|
|
This function is deprecated."
|
|
|
|
(require 'doom-themes-nlinum))
|
|
|
|
|
2016-09-12 14:06:43 +00:00
|
|
|
(provide 'doom-themes)
|
|
|
|
;;; doom-themes.el ends here
|