rice

personal dot files and scripts for linux and macOS
Log | Files | Refs | README | LICENSE

acme-theme.el (20393B)


      1 ;;; acme-theme.el --- A theme for prose.
      2 
      3 ;; Copyright 2018-now Kunal Bhalla
      4 
      5 ;; Author: Kunal Bhalla <bhalla.kunal@gmail.com>
      6 ;; URL: https://github.com/kunalb/acme/
      7 ;; Version: 2.0
      8 
      9 ;;; Commentary:
     10 
     11 ;; Emacs has very good support for multiple fonts in a single
     12 ;; file.  Acme uses this support to make it much more convenient to
     13 ;; write prose within Emacs, with particular attention paid to
     14 ;; org-mode and markdown-mode.  Code blocks, tables, etc are
     15 ;; formatted in monospace text with the appropriate backgrounds.
     16 
     17 ;; Recommended customizations for using this theme
     18 ;;
     19 ;; - Set up the base fonts you'd like to use in Emacs before loading Acme
     20 ;;     (set-face-attribute 'default nil :family "Iosevka" :height 130)
     21 ;;     (set-face-attribute 'fixed-pitch nil :family "Iosevka")
     22 ;;     (set-face-attribute 'variable-pitch nil :family "Baskerville")
     23 ;;   On loading this theme captures the default and treats that for fixed-pitch
     24 ;;   rendering.
     25 ;;
     26 ;; - Enable variable pitch mode for editing text
     27 ;; (add-hook 'text-mode-hook
     28 ;;            (lambda ()
     29 ;;             (variable-pitch-mode 1))
     30 ;;
     31 ;; - Some other modes I like to enable/disable
     32 ;;     (olivetti-mode 1)        ;; Centers text in the buffer
     33 ;;     (flyspell-mode 1)        ;; Catch Spelling mistakes
     34 ;;     (typo-mode 1)            ;; Good for symbols like em-dash
     35 ;;     (blink-cursor-mode 0)    ;; Reduce visual noise
     36 ;;     (linum-mode 0)           ;; No line numbers for prose
     37 ;;
     38 ;; - And prettier org mode bullets:
     39 ;;     (setq org-bullets-bullet-list
     40 ;;         '("◉" "○"))
     41 ;;     (org-bullets 1)
     42 
     43 ;;; Code:
     44 
     45 ;; (set-face-attribute 'default nil :family "Roboto Mono")
     46 ;; (set-face-attribute 'default nil :family "Fira Mono")
     47 ;; (set-face-attribute 'default nil :family "Iosevka Slab")
     48 ;; (set-face-attribute 'default nil :family "Hack")
     49 (set-face-attribute 'default nil :family "Roboto Mono")
     50 (set-face-attribute 'fixed-pitch nil :family "Roboto Mono")
     51 ;; (set-face-attribute 'default nil :family "GNUTypewriter")
     52 
     53 ;; (set-face-attribute 'variable-pitch nil :family "Noto Sans Bold")
     54 
     55 (defvar acme--monospace-height
     56  (face-attribute 'fixed-pitch :height nil 'default)
     57  "The original height stored as a defvar to stay constant across reloads.")
     58 
     59 (defun acme--height (multiplier)
     60  "Scale up the height according to the MULTIPLIER."
     61  (truncate (* acme--monospace-height multiplier)))
     62 
     63 (defvar mode-line-spacing 5)
     64 
     65 (deftheme acme
     66   "A prose friendly theme.")
     67 
     68 (make-face 'mode-line-height)
     69 
     70 (let (
     71       ;; Primary Colors
     72       (fg "#444444")
     73       (bg "#FFFFea")
     74 
     75       (modeline "#EAFFFF")
     76       (modeline-border "#8888cc")
     77 
     78       (white-light  "#ffffff")
     79       (yellow-light "#fff59d")
     80       (red-light    "#ff1744")
     81 
     82       (black  "gray0")
     83       (white  "gray88")
     84       (yellow "#fff176")
     85       (blue   "#0288D1")
     86       (green  "#388E3C")
     87       (red    "#bf360c")
     88       (purple "#673AB7")
     89       (brown  "#8D6E63")
     90 
     91       ;; dark colors
     92       (cyan-dark   "#455A64")
     93       (blue-dark   "#3f51b5")
     94       (red-dark    "#8E3C38")
     95       (purple-dark "#6C3082")
     96       (brown-dark  "#4e342e")
     97       )
     98   (let (
     99         (emph "gray13")
    100         (sep "gray70")
    101         (hlt "gray93")
    102         (bg-hlt "#e4e4e4")
    103         (meta brown-dark)
    104         (link "#303f9f")
    105         (link-underline "#304ffe")
    106         (vlink-underline "#1a237e")
    107         (button "gray27")
    108         (cursor "gray29")
    109         (paren-match-bg red-light)
    110         (paren-match-fg white-light)
    111         (search-fg red)
    112         (search-bg white-light)
    113         (search-fail-bg "#f8bbd0")
    114         (tooltip-fg "#111111")
    115         (tooltip-bg yellow)
    116         (shadow "grey60")
    117         (secondary-bg yellow-light)
    118         (trailing-bg "#ff8a65")
    119         (fci "grey87")
    120         (mode-line-fg "grey7")
    121         (mode-line-hlt white-light)
    122         (mode-line-inactive "#888888")
    123         (header red-dark)
    124         (header-line-bg white)
    125         (builtin red-dark)
    126         (string green)
    127         (function-name "#444444")
    128         (keyword "#444444")
    129         (constant blue)
    130         (type "#444444")
    131         (variable cyan-dark)
    132 
    133         ;; org
    134         (org-meta                brown)
    135         (org-document-info       brown)
    136         (org-table               white)
    137         (org-quote-fg            purple-dark)
    138         (org-quote-bg            white)
    139         (org-date                "#444444")
    140         (org-title               red)
    141         (org-title-underline     "#aaaaaa")
    142         (org-checkbox            "#aaaaaa")
    143         (org-scheduled           "#333333")
    144         (org-scheduled-today     "#111111")
    145         (org-done                green)
    146         (org-todo                red)
    147         (org-tag                 "#777777")
    148         (org-block-line          "#d0d0d0")
    149         (org-block-bg            white)
    150         (org-agenda-structure-fg "#555555")
    151         (org-agenda-structure-bg white)
    152         (org-agenda-today-fg     "#000000")
    153         (org-agenda-today-bg     "#eeeeee")
    154         (org-special-keyword     "#777777")
    155         (org-sched-prev          "#222222")
    156         (org-agenda-done         "#777777")
    157 
    158         (hl-line "#efefef")
    159         (linum-hlt "#555555")
    160         (linum "#aaaaaa")
    161         (markdown-markup brown)
    162         (markdown-metadata "#777777")
    163         (markdown-language purple)
    164         (markdown-list "#000000")
    165         (markdown-code-bg white)
    166         (markdown-pre-bg white)
    167         (markdown-header-delimiter brown)
    168         (imenu brown-dark))
    169 
    170     
    171 (set-face-attribute 
    172     (custom-theme-set-faces 'acme
    173                             `(variable-pitch ((t (:family ,(face-attribute 'variable-pitch :family) :height ,(acme--height 1.25)))))
    174 
    175                             `(default ((t (:background ,bg :foreground ,fg))))
    176                             `(italic ((t (:foreground ,emph :slant italic))))
    177                             `(highlight ((t (:background ,hlt :overline nil))))
    178                             `(region ((t (:background ,bg-hlt))))
    179                             `(fringe ((t (:background ,bg))))
    180                             `(button ((t (:inherit default :foreground ,button))))
    181                             `(escape-glyph ((t (:foreground ,purple))))
    182                             `(link ((t (:underline (:color ,link-underline :style line) :foreground ,link))))
    183                             `(link-visited ((t (:inherit link :foreground ,link :underline (:color ,vlink-underline :style line)))))
    184                             `(cursor ((t (:background ,cursor))))
    185                             `(show-paren-match ((t (:background ,paren-match-fg :foreground ,paren-match-bg))))
    186                             `(isearch ((t (:foreground ,search-fg :background ,search-bg))))
    187                             `(isearch-fail ((t (:background ,search-fail-bg))))
    188                             `(query-replace ((t (:inherit isearch))))
    189                             `(tooltip ((t (:inherit default :foreground ,tooltip-fg :background ,tooltip-bg))))
    190                             `(shadow ((t (:foreground ,shadow))))
    191                             `(secondary-selection ((t (:background ,secondary-bg))))
    192                             `(trailing-whitespace ((t (:background ,trailing-bg))))
    193                             `(lazy-highlight ((t (:foreground ,black :background ,white-light))))
    194                             `(next-error ((t (:inherit region))))
    195                             `(window-divider ((t (:background ,sep :foreground ,sep))))
    196                             `(vertical-border ((t (:background ,sep :foreground ,sep))))
    197                             `(minibuffer-prompt ((t (:inherit fixed-pitch :weight bold :foreground ,meta))))
    198 
    199                             ;; mode line
    200 
    201 
    202                             `(header-line         ((t (:overline nil :background ,header-line-bg :box (:line-width 1 :color "#8888cc") :underline ,sep :inherit mode-line))))
    203                             `(mode-line           ((t (:inherit fixed-pitch :foreground ,mode-line-fg       :background ,modeline :overline ,modeline-border :box (:line-width 1 :color ,modeline-border)))))
    204                             `(mode-line-inactive  ((t (:inherit fixed-pitch :foreground ,mode-line-inactive :background ,modeline :overline ,modeline-border :box (:line-width 1 :color ,modeline-border)))))
    205                             `(mode-line-height    ((t (:foreground ,modeline-border :background ,modeline-border :box (:line-width ,mode-line-spacing :color ,modeline-border)))))
    206 
    207                             `(mode-line-buffer-id ((t (:weight bold))))
    208                             `(mode-line-emphasis  ((t (:weight bold))))
    209                             `(mode-line-highlight ((t (:background ,mode-line-hlt))))
    210 
    211                             `(error ((t (:inherit fixed-pitch))))
    212 
    213                             ;; primary font lock
    214                             `(font-lock-comment-face ((t (:foreground ,shadow :inherit fixed-pitch))))
    215                             `(font-lock-builtin-face ((t (:foreground ,builtin :inherit fixed-pitch))))
    216                             `(font-lock-string-face  ((t (:inherit fixed-pitch :foreground ,string))))
    217                             `(font-lock-function-name-face ((t (:inherit fixed-pitch :foreground ,function-name))))
    218                             `(font-lock-keyword-face ((t (:inherit fixed-pitch :weight bold :foreground ,keyword))))
    219                             `(font-lock-comment-delimiter-face ((t (:inherit fixed-pitch :inherit font-lock-comment-face))))
    220                             `(font-lock-constant-face ((t (:inherit fixed-pitch))))
    221                             `(font-lock-doc-face ((t (:inherit fixed-pitch :inherit font-lock-string-face))))
    222                             `(font-lock-preprocessor-face ((t (:inherit fixed-pitch :inherit font-lock-builtin-face))))
    223                             `(font-lock-regexp-grouping-backslash ((t (:inherit fixed-pitch :inherit bold))))
    224                             `(font-lock-regexp-grouping-construct ((t (:inherit fixed-pitch :inherit bold))))
    225                             `(font-lock-type-face ((t (:inherit fixed-pitch))))
    226                             `(font-lock-variable-name-face ((t (:inherit fixed-pitch :foreground ,variable))))
    227                             `(font-lock-warning-face ((t (:inherit error))))
    228 
    229                             ;; Org
    230                             `(org-level-1 ((t (:inherit default :foreground ,header :height ,(acme--height 1.5)))))
    231                             `(org-level-2 ((t (:inherit default :foreground ,header :height ,(acme--height 1.4)))))
    232                             `(org-level-3 ((t (:inherit default :foreground ,header :height ,(acme--height 1.3)))))
    233                             `(org-level-4 ((t (:inherit default :foreground ,header :height ,(acme--height 1.23)))))
    234                             `(org-level-5 ((t (:inherit default :foreground ,header :height ,(acme--height 1.23)))))
    235                             `(org-level-6 ((t (:inherit default :foreground ,header :height ,(acme--height 1.23)))))
    236                             `(org-level-7 ((t (:inherit default :foreground ,header :height ,(acme--height 1.23)))))
    237                             `(org-level-8 ((t (:inherit default :foreground ,header :height ,(acme--height 1.23)))))
    238                             `(org-meta-line ((t (:inherit fixed-pitch :foreground ,org-meta))))
    239                             `(org-document-info-keyword ((t (:inherit fixed-pitch :foreground ,org-document-info))))
    240                             `(org-document-info ((t (:inherit default :foreground ,org-document-info))))
    241                             `(org-verbatim ((t (:inherit fixed-pitch))))
    242                             `(org-table ((t (:inherit fixed-pitch :background ,org-table))))
    243                             `(org-formula ((t (:inherit org-table :height ,(acme--height 1)))))
    244                             `(org-quote ((t (:inherit default :foreground ,org-quote-fg :background ,org-quote-bg))))
    245                             `(org-hide ((t (:inherit fixed-pitch :foreground ,bg))))
    246                             `(org-indent ((t (:inherit org-hide))))
    247                             `(org-date ((t (:inherit fixed-pitch :foreground ,org-date :underline nil))))
    248                             `(org-document-title ((t (:inherit default :foreground ,org-title :height ,(acme--height 1.8) :underline (:color ,org-title-underline)))))
    249                             `(org-checkbox ((t (:inherit fixed-pitch :weight bold :foreground ,org-checkbox))))
    250                             `(org-scheduled ((t (:foreground ,org-scheduled))))
    251                             `(org-scheduled-today ((t (:foreground ,org-scheduled-today))))
    252                             `(org-done ((t (:inherit fixed-pitch :foreground ,org-done))))
    253                             `(org-todo ((t (:inherit fixed-pitch :foreground ,org-todo))))
    254                             `(org-tag ((t (:inherit fixed-pitch :height ,(acme--height 1) :foreground ,org-tag))))
    255                             `(org-block-begin-line ((t (:inherit fixed-pitch :background ,org-block-line))))
    256                             `(org-block-end-line ((t (:inherit fixed-pitch :background ,org-block-line))))
    257                             `(org-block ((t (:background ,org-block-bg :inherit fixed-pitch))))
    258                             `(org-priority ((t (:inherit fixed-pitch :weight normal))))
    259                             `(org-agenda-structure ((t (:foreground ,org-agenda-structure-fg :background ,org-agenda-structure-bg :overline ,org-agenda-structure-bg :underline ,org-agenda-structure-bg))))
    260                             `(org-agenda-date-weekend ((t (:inherit org-agenda-structure))))
    261                             `(org-agenda-date-today ((t (:foreground ,org-agenda-today-fg :overline ,org-agenda-today-bg :background ,org-agenda-today-bg :underline ,org-agenda-today-bg))))
    262                             `(org-special-keyword ((t (:inherit fixed-pitch :foreground ,org-special-keyword))))
    263                             `(org-scheduled-previously ((t (:foreground ,org-sched-prev))))
    264                             `(org-agenda-done ((t (:foreground ,org-agenda-done))))
    265                             `(org-footnote ((t (:foreground ,link))))
    266                             `(hl-line ((t (:background ,hl-line))))
    267 
    268                             ;; line numbers
    269                             `(line-number ((t (:inherit fixed-pitch :foreground ,linum))))
    270                             `(line-number-current-line ((t (:inherit fixed-pitch :foreground ,linum-hlt))))
    271 
    272                             ;; markdown
    273                             `(markdown-header-face-1 ((t (:foreground ,header :inherit default :height ,(acme--height 1.5)))))
    274                             `(markdown-header-face-2 ((t (:foreground ,header :inherit default :height ,(acme--height 1.4)))))
    275                             `(markdown-header-face-3 ((t (:foreground ,header :inherit default :height ,(acme--height 1.3)))))
    276                             `(markdown-header-face-4 ((t (:foreground ,header :inherit default :height ,(acme--height 1.23)))))
    277                             `(markdown-header-face-5 ((t (:foreground ,header :inherit default :height ,(acme--height 1.23)))))
    278                             `(markdown-header-face-6 ((t (:foreground ,header :inherit default :height ,(acme--height 1.23)))))
    279                             `(markdown-header-face-7 ((t (:foreground ,header :inherit default :height ,(acme--height 1.23)))))
    280                             `(markdown-header-face-8 ((t (:foreground ,header :inherit default :height ,(acme--height 1.23)))))
    281                             `(markdown-markup-face ((t (:inherit fixed-pitch :foreground ,markdown-markup))))
    282                             `(markdown-inline-code-face ((t (:inherit fixed-pitch))))
    283                             `(markdown-metadata-key-face ((t (:inherit fixed-pitch :height ,(acme--height 1) :foreground ,markdown-metadata))))
    284                             `(markdown-metadata-value-face ((t (:inherit fixed-pitch :height ,(acme--height 1) :foreground ,fg))))
    285                             `(markdown-language-keyword-face ((t (:foreground ,markdown-language))))
    286                             `(markdown-list-face ((t (:inherit fixed-pitch :foreground ,markdown-list))))
    287                             `(markdown-code-face ((t (:inherit fixed-pitch :foreground ,fg :background ,markdown-code-bg))))
    288                             `(markdown-pre-face ((t (:inherit fixed-pitch :color ,fg :background ,markdown-pre-bg))))
    289                             `(markdown-header-delimiter-face ((t (:inherit fixed-pitch :foreground ,markdown-header-delimiter))))
    290                             `(markdown-header-rule-face ((t (:inherit fixed-pitch :foreground ,markdown-header-delimiter))))
    291                             `(markdown-url-face ((t (:inherit fixed-pitch :foreground ,link))))
    292 
    293                             ;; ivy
    294                             `(ivy-current-match ((t (:inherit fixed-pitch :background ,hlt))))
    295                             `(ivy-minibuffer-match-face-1 ((t (:inherit fixed-pitch :foreground  ,cyan-dark))))
    296                             `(ivy-minibuffer-match-face-2 ((t (:inherit fixed-pitch :foreground ,red-dark))))
    297                             `(ivy-minibuffer-match-face-3 ((t (:inherit fixed-pitch :foreground ,blue-dark))))
    298                             `(ivy-minibuffer-match-face-4 ((t (:inherit fixed-pitch :foreground ,brown-dark))))
    299 
    300                             ;; imenu
    301                             `(imenu-list-entry-face-0 ((t (:foreground ,imenu))))
    302                             `(imenu-list-entry-face-1 ((t (:foreground ,imenu))))
    303                             `(imenu-list-entry-face-2 ((t (:foreground ,imenu))))
    304                             `(imenu-list-entry-face-3 ((t (:foreground ,imenu))))
    305                             `(imenu-list-entry-face-4 ((t (:foreground ,imenu))))
    306                             `(imenu-list-entry-face-5 ((t (:foreground ,imenu))))
    307 
    308                             ;; tldr
    309                             `(tldr-title       ((t (:foreground ,red :weight bold :height 1.9))))
    310                             `(tldr-description ((t (:foreground ,green))))
    311                             `(tldr-code-block  ((t ())))
    312                             `(tldr-command-argument ((t ())))
    313 
    314                             ; Dired subtree
    315                             `(dired-subtree-depth-1-face ((t (:backround ,bg))))
    316                             `(dired-subtree-depth-2-face ((t (:backround ,bg))))
    317                             `(dired-subtree-depth-3-face ((t (:backround ,bg))))
    318                             `(dired-subtree-depth-4-face ((t (:backround ,bg))))
    319                             `(dired-subtree-depth-5-face ((t (:backround ,bg))))
    320                             `(dired-subtree-depth-6-face ((t (:backround ,bg))))
    321 
    322                             ; Company
    323                             `(company-tooltip-selection        ((t (:background "#ddffdd"))))
    324                             `(company-tooltip-selection        ((t (:background "#cee7cf"))))
    325                             `(company-tooltip-common           ((t (:inherit fixed-pitch :foreground nil :underline nil :weight bold))))
    326                             `(company-scrollbar-fg             ((t (:background "#388E3C"))))
    327                             `(company-preview-common           ((t (:underline nil))))
    328                             `(company-tooltip-common           ((t (:underline nil))))
    329                             `(company-tooltip-common-selection ((t (:underline nil))))
    330 
    331                             ;; evil
    332                             `(evil-ex-substitute-replacement ((t (:foreground ,white-light :background ,brown-dark :underline nil))))
    333                             `(evil-goggles-delete-face ((t (:inherit 'lazy-highlight))))
    334                             `(evil-goggles-paste-face  ((t (:inherit 'lazy-highlight))))
    335                             `(evil-goggles-yank-face   ((t (:inherit 'lazy-highlight))))
    336 
    337                             `(helm-source-header ((t (:height ,(acme--height 1))))))
    338 
    339     (custom-theme-set-variables 'acme
    340                                 '(line-spacing 0.4)
    341                                 `(fci-rule-color ,fci)))))
    342 
    343 ;;;###autoload
    344 (when (and (boundp 'custom-theme-load-path)
    345            load-file-name)
    346   (add-to-list 'custom-theme-load-path
    347                (file-name-as-directory
    348                 (file-name-directory load-file-name))))
    349 
    350 (provide-theme 'acme)
    351 ;;; acme-theme.el ends here