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-05-01 08:58:17 +00:00
|
|
|
;; Modified: May 1, 2017
|
|
|
|
;; Version: 1.2.1
|
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:
|
|
|
|
;;
|
|
|
|
;; An opinionated UI plugin/pack of themes extracted from my emacs.d, inspired
|
|
|
|
;; by the One Dark/Light UI and syntax themes in Atom.
|
|
|
|
;;
|
|
|
|
;; Includes optional dimming of non-source buffers, a neotree theme with font
|
|
|
|
;; icons, and (soon) a mode-line config.
|
|
|
|
;;
|
|
|
|
;; Currently available colorschemes:
|
|
|
|
;; + doom-one: inspired by Atom One Dark
|
|
|
|
;; + doom-dark: based on Molokai
|
|
|
|
;;
|
|
|
|
;; Soon to come:
|
2017-01-10 20:04:17 +00:00
|
|
|
;; + doom-one-light: inspired by Atom One Light
|
|
|
|
;; + doom-tron: doom-one, but with daylerees' Tron Legacy colorscheme
|
|
|
|
;; + doom-peacock: doom-one, but with daylerees' Peacock colorscheme
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
|
|
|
;;
|
|
|
|
;; ## Configuration
|
|
|
|
;;
|
2017-01-10 20:04:17 +00:00
|
|
|
;; + global
|
|
|
|
;; + `doom-enable-bold` (default: `t`): if nil, bolding will be disabled
|
|
|
|
;; across all faces.
|
|
|
|
;; + `doom-enable-italic` (default: `t`): if nil, italicization will be
|
|
|
|
;; disabled across all faces.
|
|
|
|
;; + doom-one
|
|
|
|
;; + `doom-one-brighter-modeline` (default: `nil`): If non-nil, the
|
|
|
|
;; mode-line background is slightly brighter.
|
|
|
|
;; + `doom-one-brighter-comments` (default: `nil`): If non-nil, comments
|
|
|
|
;; are brighter and easier to see.
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
|
|
|
;;
|
|
|
|
;; ## Installation
|
|
|
|
;;
|
2016-10-04 21:09:43 +00:00
|
|
|
;; 1. Install from MELPA `M-x package-install RET doom-themes`, or clone
|
|
|
|
;; the repo somewhere in your `load-path`.
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
2016-10-04 21:09:43 +00:00
|
|
|
;; 2. If you want the neotree theme, download and install the fonts included
|
|
|
|
;; with all-the-icons.
|
|
|
|
;;
|
|
|
|
;; 3. `(require 'doom-themes)` and then load the theme you want.
|
|
|
|
;;
|
|
|
|
;; Example configuration:
|
2016-09-12 14:06:43 +00:00
|
|
|
;;
|
|
|
|
;; (require 'doom-themes)
|
|
|
|
;; (load-theme 'doom-one t) ;; or doom-dark, etc.
|
|
|
|
;;
|
2016-10-04 21:09:43 +00:00
|
|
|
;; ;;; OPTIONAL
|
2016-09-15 15:52:04 +00:00
|
|
|
;; ;; brighter source buffers
|
|
|
|
;; (add-hook 'find-file-hook 'doom-buffer-mode)
|
|
|
|
;; ;; brighter minibuffer when active
|
|
|
|
;; (add-hook 'minibuffer-setup-hook 'doom-brighten-minibuffer)
|
|
|
|
;; ;; Custom neotree theme
|
|
|
|
;; (require 'doom-neotree)
|
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
|
|
|
|
"Options for doom-themes"
|
|
|
|
:group 'faces)
|
|
|
|
|
|
|
|
(defface doom-default '((t (:inherit default)))
|
|
|
|
"Background face for source code windows."
|
|
|
|
:group 'doom-themes)
|
|
|
|
|
|
|
|
(defface doom-minibuffer-active '((t (:inherit mode-line)))
|
|
|
|
"Face for active minibuffer. See `doom-enable-bright-minibuffer'."
|
|
|
|
:group 'doom-themes)
|
|
|
|
|
|
|
|
(defface doom-linum '((t (:inherit linum)))
|
|
|
|
"Another linum face for darker windows (like popups)."
|
|
|
|
:group 'doom-themes)
|
|
|
|
|
|
|
|
(defface doom-nlinum-highlight '((t (:inherit linum)))
|
|
|
|
"A face for the nlinum overlay on the current line."
|
|
|
|
:group 'doom-themes)
|
|
|
|
|
|
|
|
(defface doom-hl-line '((t (:inherit hl-line)))
|
|
|
|
"A face for the current line highlight."
|
|
|
|
:group 'doom-themes)
|
|
|
|
|
2016-12-07 06:38:25 +00:00
|
|
|
(defface doom-org-hide '((t (:inherit org-hide)))
|
|
|
|
"A face for hidden elements in org-mode. Only active if `doom-buffer-mode' is active."
|
|
|
|
:group 'doom-themes)
|
|
|
|
|
2016-09-19 15:40:51 +00:00
|
|
|
;;
|
|
|
|
(defcustom doom-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)
|
|
|
|
|
|
|
|
(defcustom doom-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-01 08:06:22 +00:00
|
|
|
(defvar doom--colors nil
|
2017-05-01 18:19:44 +00:00
|
|
|
"An alist of the color definitions for the currently active doom theme.")
|
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)"
|
2016-09-19 15:40:51 +00:00
|
|
|
(apply (lambda (r g b) (format "#%02x%02x%02x" (* r 255) (* g 255) (* b 255)))
|
2017-01-11 01:03:29 +00:00
|
|
|
(cl-mapcar (lambda (it other) (+ (* alpha it) (* other (- 1 alpha))))
|
|
|
|
(doom-name-to-rgb color1)
|
|
|
|
(doom-name-to-rgb color2))))
|
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)."
|
2016-09-19 15:40:51 +00:00
|
|
|
(doom-blend color "#000000" (- 1 alpha)))
|
|
|
|
|
|
|
|
(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)."
|
2016-09-19 15:40:51 +00:00
|
|
|
(doom-blend color "#FFFFFF" (- 1 alpha)))
|
|
|
|
|
|
|
|
(defun doom--face-remap-add-relative (orig-fn &rest args)
|
2017-05-01 08:08:13 +00:00
|
|
|
"Ensure that other themes, functions or packages that use
|
|
|
|
`face-remap-add-relative' (like `text-scale-set') don't undo doom's overriden
|
|
|
|
faces."
|
2016-09-19 15:40:51 +00:00
|
|
|
(when (and (display-graphic-p) doom-buffer-mode)
|
|
|
|
(let ((remap (assq (nth 0 args) face-remapping-alist)))
|
|
|
|
(when remap (setf (nth 0 args) (cadr remap)))))
|
|
|
|
(apply orig-fn args))
|
|
|
|
(advice-add 'face-remap-add-relative :around 'doom--face-remap-add-relative)
|
|
|
|
|
2017-05-01 08:06:22 +00:00
|
|
|
(defmacro def-doom-theme (name docstring defs faces &optional vars)
|
|
|
|
"Define a DOOM theme."
|
|
|
|
(declare (doc-string 2))
|
|
|
|
`(let* ((c '((class color) (min-colors 89)))
|
2017-05-01 16:30:13 +00:00
|
|
|
(gui (or (display-graphic-p) (= (tty-display-color-cells) 16777216)))
|
2017-05-01 08:06:22 +00:00
|
|
|
(bold doom-enable-bold)
|
|
|
|
(italic doom-enable-italic)
|
|
|
|
,@defs)
|
2017-05-01 18:19:44 +00:00
|
|
|
(setq doom--colors ',defs)
|
2017-05-01 08:06:22 +00:00
|
|
|
(deftheme ,name ,docstring)
|
|
|
|
(custom-theme-set-faces ',name ,@faces)
|
|
|
|
,(when vars `(custom-theme-set-variables ',name ,@vars))
|
|
|
|
(provide-theme ',name)))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom-color (name)
|
2017-05-01 18:19:44 +00:00
|
|
|
"Retrieve a specific color named NAME (a symbol) from the current DOOM theme."
|
|
|
|
(nth 1 (assq name doom--colors)))
|
2017-05-01 08:06:22 +00:00
|
|
|
|
2016-09-19 15:40:51 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom-brighten-minibuffer ()
|
2017-05-01 18:19:44 +00:00
|
|
|
"Highlight the minibuffer whenever it is in use."
|
2016-09-19 15:40:51 +00:00
|
|
|
(with-selected-window (minibuffer-window)
|
|
|
|
(setq-local face-remapping-alist
|
|
|
|
(append face-remapping-alist '((default doom-minibuffer-active))))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(define-minor-mode doom-buffer-mode
|
|
|
|
"Brighten source buffers by remapping common faces (like default, hl-line and
|
|
|
|
linum) to their doom-theme variants."
|
|
|
|
:lighter " doom"
|
|
|
|
:init-value nil
|
|
|
|
(if doom-buffer-mode
|
|
|
|
(progn
|
|
|
|
;; Don't reset remapped faces on `kill-all-local-variables'
|
|
|
|
(make-variable-buffer-local 'face-remapping-alist)
|
|
|
|
(put 'face-remapping-alist 'permanent-local t)
|
|
|
|
;; Brighten up file buffers; darken special and popup buffers
|
|
|
|
(set-face-attribute 'fringe nil :background (face-attribute 'doom-default :background))
|
2016-12-07 06:38:25 +00:00
|
|
|
;; Update `doom-org-hide'
|
2016-09-19 15:40:51 +00:00
|
|
|
(setq-local face-remapping-alist
|
|
|
|
(append face-remapping-alist
|
|
|
|
'((default doom-default)
|
|
|
|
(hl-line doom-hl-line)
|
2017-05-01 04:37:07 +00:00
|
|
|
(linum doom-linum)
|
|
|
|
(org-hide doom-org-hide)))))
|
2016-09-19 15:40:51 +00:00
|
|
|
(set-face-attribute 'fringe nil :background (face-attribute 'default :background))
|
|
|
|
(put 'face-remapping-alist 'permanent-local nil)
|
|
|
|
;; Remove face remaps
|
|
|
|
(mapc (lambda (key) (setq-local face-remapping-alist (assq-delete-all key face-remapping-alist)))
|
2017-05-01 04:37:07 +00:00
|
|
|
'(default hl-line linum org-hide))))
|
2016-09-19 15:40:51 +00:00
|
|
|
|
2017-02-22 22:11:50 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom-buffer-mode-maybe ()
|
|
|
|
"Enable `doom-buffer-mode' in the current buffer, if it isn't already and the
|
|
|
|
buffer represents a real file."
|
|
|
|
(when (and (not doom-buffer-mode)
|
|
|
|
buffer-file-name)
|
|
|
|
(doom-buffer-mode +1)))
|
|
|
|
|
2016-09-19 15:40:51 +00:00
|
|
|
;;;###autoload
|
|
|
|
(when (and (boundp 'custom-theme-load-path) load-file-name)
|
|
|
|
(add-to-list 'custom-theme-load-path
|
|
|
|
(file-name-as-directory (file-name-directory load-file-name))))
|
|
|
|
|
2016-09-12 14:06:43 +00:00
|
|
|
(provide 'doom-themes)
|
|
|
|
;;; doom-themes.el ends here
|