aboutsummaryrefslogtreecommitdiff
path: root/bard-elisp/bard-theme.el
blob: f006a1860b59b9b807c2a628f3b6c38354e4934f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
(setq fontaine-presets
      '((default
         :default-height 140
         :default-family "Iosevka Comfy"
         :variable-pitch-family "Iosevka Comfy"
         :variable-pitch-height 1.0
         :fixed-pitch-family "Iosevka Comfy"
         :fixed-pitch-height 1.0
         :bold-weight bold
         )
        (tiny
         :inherit default
         :default-height 135)
        (wide
         :default-height 135
         :default-family "Iosevka Comfy Wide"
         :fixed-pitch-family "Iosevka Comfy Wide"
         :variable-pitch-family "Iosevka Comfy Wide Motion Duo")
        (prot
         :default-family "Iosevka Comfy Wide Motion"
         :default-height 130
         :default-weight medium
         :fixed-pitch-family "Iosevka Comfy Wide Motion"
         :variable-pitch-family "Iosevka Comfy Wide Motion Duo"
         :bold-weight extrabold)
        (mono
         :default-height 130
         :default-family "monospace"
         :fixed-pitch-family "monospace"
         :variable-pitch-family "Baskerville"
         :variable-pitch-height 140)
        (mono-large
         :inherit mono
         :default-height 150
         :variable-pitch-height 160)
        (mac
         :default-height 130
         :default-family "Monaco"
         :variable-pitch-family "Monaco"
         :fixed-pitch-family "Monaco")
        (bit
         :default-height 140
         :default-family "Ttyp0 OTB"
         :variable-pitch-family "Ttyp0 OTB"
         :fixed-pitch-family "Ttyp0 OTB")
        (large
         :inherit default
         :default-height 160)
        (huge
         :inherit default
         :default-height 180)
        (t
         :default-family "Monospace")))

(set-fontset-font
 t 'han
 (font-spec :family "Noto Serif CJK JP") nil 'prepend)

(defun bard/disable-all-themes ()
  "disable all active themes."
  (interactive)
  (dolist (i custom-enabled-themes)
    (disable-theme i)))

(defvar bard/after-theme-load-hook nil
  "Hook that runs after a new theme is loaded using `bard/select-theme`.")

(dolist (hook '(bard/after-theme-load-hook))
  (add-hook hook #'fontaine-apply-current-preset)
  (add-hook hook #'logos-update-fringe-in-buffers))

(defun bard/select-theme (&optional theme)
  "Enable the specified THEME, or prompt the user to select one if THEME is nil."
  (interactive
   (list
    (completing-read "Select theme: "
                     (mapcar 'symbol-name (custom-available-themes)))))
  (let* ((theme-symbol (if (symbolp theme) theme (intern theme)))
         (theme-name (symbol-name theme-symbol))
         (display-theme-name (if (string-suffix-p "-theme" theme-name)
                                 (substring theme-name 0 -6)
                               theme-name))
         (colored-theme-name (propertize display-theme-name 'face '(:weight bold))))
    (bard/disable-all-themes)
    (load-theme theme-symbol t)
    (message "Loaded the %s theme" colored-theme-name)
    (run-hooks 'bard/after-theme-load-hook)))

(defvar my-last-cursor-type nil)

(defun bard/update-cursor-type ()
  "Set cursor type to 'bar in text modes, 'box otherwise.
leave it alone in pdf-view-mode."
  (unless (derived-mode-p 'pdf-view-mode)
    (let ((new-cursor (if (derived-mode-p 'text-mode) 'bar 'box)))
      (unless (eq my-last-cursor-type new-cursor)
        (setq cursor-type new-cursor)
        (setq my-last-cursor-type new-cursor)))))

(add-hook 'post-command-hook #'bard/update-cursor-type)

(defun bard/outline-heading-faces ()
  (set-face-attribute 'org-document-title nil
                      :inherit '(outline-1 variable-pitch)
                      :weight 'light
                      :height 1.5)

  (set-face-attribute 'org-level-1 nil
                      :inherit '(outline-2 variable-pitch)
                      :weight 'light
                      :height 1.3)

  (set-face-attribute 'org-level-2 nil
                      :inherit 'outline-3
                      :height 1.2)

  (set-face-attribute 'org-level-3 nil
                      :inherit '(outline-4 variable-pitch)
                      :height 1.1)

  (set-face-attribute 'org-level-4 nil
                      :inherit '(outline-5 variable-pitch)
                      :height 1.1)

  (set-face-attribute 'org-level-5 nil
                      :inherit '(outline-6 variable-pitch)
                      :height 1.1)

  (set-face-attribute 'org-level-6 nil
                      :inherit '(outline-6 variable-pitch)
                      :height 1.1)

  (set-face-attribute 'org-agenda-date nil
                      :inherit 'variable-pitch
                      :weight 'bold
                      :height 1.3)

  (set-face-attribute 'org-agenda-structure nil
                      :inherit 'variable-pitch
                      :weight 'bold
                      :height 1.5))

(add-hook 'bard/after-theme-load-hook #'bard/outline-heading-faces)

(provide 'bard-theme)