~hristoast/dot-emacs

ref: 2bb9a7dd5ca8cb281c4f8a9a8bea0508464b5c63 dot-emacs/lib/ui.el -rw-r--r-- 8.3 KiB
2bb9a7ddHristos N. Triantafillou A post-install note 4 months ago
                                                                                
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
;;; ui.el --- User interface changes.
;;; Commentary:
;; User interface changes.
;;; Code:

(unless (getenv "EMACS_NO_ALERT")
  ;; https://github.com/jwiegley/alert
  ;; A Growl-like alerts notifier for Emacs
  (use-package alert
    :straight t
    :config
    (let ((h/alert/styles
           #s(hash-table
              size 8
              test equal
              data
              ("growl" growl
               "libnotify" libnotify
               "log" log
               "message" message
               "mode-line" mode-line
               "notifications" notifications
               "osx-notifier" osx-notifier
               "x11" x11)))
          (h/alert/default-style "libnotify"))
      (setq-default alert-default-style (gethash (or (getenv "EMACS_ALERT_STYLE") h/alert/default-style)
                                                 h/alert/styles nil)))))

(unless (getenv "EMACS_NO_DIFF_HL") ;; Don't use diff-hl.
  ;; diff-hl - highlight changes/diffs
  ;; https://github.com/dgutov/diff-hl
  (use-package diff-hl
    :straight t
    :config
    (global-diff-hl-mode)))

(unless (getenv "EMACS_NO_DASHBOARD")
  ;; An extensible emacs startup screen showing you what’s most important.
  ;; https://github.com/emacs-dashboard/emacs-dashboard
  (use-package dashboard
    :straight t
    :config
    (dashboard-setup-startup-hook)
    ;; Allow banner customization through an environment variable
    (let ((h/dashboard/banners
           #s(hash-table
              size 5
              test equal
              data
              ("official" official
               "logo" logo
               "1" 1
               "2" 2
               "3" 3)))
          (h/dashboard/default-banner "logo"))
      (setq
       dashboard-banner-logo-title (or (getenv "EMACS_DASHBOARD_TITLE")
                                       "Welcome to Hristos' Emacs")
       dashboard-footer-messages '("Check out: https://mousikofidi.info/"
                                   "Check out: https://openmw.org/"
                                   "Check out: https://soupault.app/"
                                   "Check out: https://sr.ht/"
                                   "Don't forget to smile!"
                                   "Hristos is proud of you!"
                                   "Keep excited and hack on!"
                                   "Pssst, try: M-x fireplace"
                                   "Smile at a stranger today."
                                   "Read about available tweaks here: https://man.sr.ht/~hristoast/dot-emacs/config.md#tweaks"
                                   "Set these environment variables for a light theme: EMACS_MATERIAL_THEME=light EMACS_SML_THEME=light"
                                   "Set these environment variables for no extra themes: EMACS_NO_SMART_MODE_LINE=t EMACS_NO_STATUS_EMOJII=t EMACS_NO_THEME=t"
                                   "Set this environment variable for the dark blue material theme: EMACS_MATERIAL_THEME_BLUE=t"
                                   "Set this environment variable to change the default org file: EMACS_DEFAULT_ORG_FILE=/path/to/file.org")
       dashboard-items '((recents  . 20)
                         (bookmarks . 20)
                         (agenda . 20))
       dashboard-set-file-icons t
       dashboard-set-heading-icons t
       dashboard-startup-banner (gethash (or (getenv "EMACS_DASHBOARD_BANNER")
                                             h/dashboard/default-banner)
                                         h/dashboard/banners nil))
      ;; Don't setup the dashboard when Emacs is started with files as command-line arguments.
      ;; https://github.com/emacs-dashboard/emacs-dashboard/issues/115#issuecomment-478167057
      (if (< (length command-line-args) 2)
          (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))))))

(unless (getenv "EMACS_NO_ALL_THE_ICONS")
  (progn
    ;; A utility package to collect various Icon Fonts and propertize them within Emacs.
    ;; https://github.com/domtronn/all-the-icons.el
    (use-package all-the-icons :straight t)
    (use-package all-the-icons-dired
      :straight t
      :hook (dired-mode . all-the-icons-dired-mode))))

;; https://github.com/akreisher/eshell-syntax-highlighting/
(unless (getenv "EMACS_NO_ESHELL_SYNTAX")
  (use-package eshell-syntax-highlighting :straight t :defer t))

(unless (getenv "EMACS_NO_FIREPLACE") ;; Don't allow Emacs to be a warm cozy fireplace.
;;; Warm cozy fireplace -- https://github.com/johanvts/emacs-fireplace
  (use-package fireplace
    :straight t
    :init (defvar fireplace-mode-map)
    :bind (:map fireplace-mode-map
                ("d" . fireplace-down)
                ("s" . fireplace-toggle-smoke)
                ("u" . fireplace-up))))

(unless (getenv "EMACS_NO_STATUS_EMOJI") ;; Don't use emoji for Flycheck's status.
  ;; Flycheck Status Emoji
  ;; https://github.com/liblit/flycheck-status-emoji
  (use-package flycheck-status-emoji
    :straight t
    :config
    (flycheck-status-emoji-mode)))

(or (getenv "EMACS_NO_SMART_MODE_LINE")
    (getenv "EMACS_NO_THEME")
    ;; A powerful and beautiful mode-line for Emacs.
    ;; https://github.com/Malabarba/smart-mode-line
    ;; TODO: Possibly add support for extra themes (e.g. powerline and solarized)
    (let ((h/sml/themes
           #s(hash-table
              size 3
              test equal
              data
              ("dark" dark
               "light" light
               "respectful" respectful)))
          (h/sml/default-theme "dark"))

      (use-package smart-mode-line
        :straight t
        :config
        (setq
         sml/shorten-directory t
         sml/theme
         (gethash (or (getenv "EMACS_SML_THEME") h/sml/default-theme)
                  h/sml/themes nil))

        (if (getenv "EMACS_TRUST_SML_THEMES")
            ;; This isn't totally cool but here's an option for it anyways:
            ;; https://github.com/Malabarba/smart-mode-line/blob/f53e380c9aadcba42ed2d4ed6ebc508b5e006519/README.org#installation-issues-faq
            (setq sml/no-confirm-load-theme t))

        (sml/setup))))

(unless (getenv "EMACS_NO_THEME") ;; Don't load a theme.
  ;; Color Theme for emacs based on material design colors
  ;; https://github.com/cpaulik/emacs-material-theme
  ;; But use my fork that always selects grey colors over darkblue.
  (use-package material-theme
    :straight (material-theme
               :type git
               :host nil
               :repo "https://git.sr.ht/~hristoast/emacs-material-theme")
    :config
    (if (getenv "EMACS_TRUST_THEMES")
        (setq h/trust-themes t)
      (setq h/trust-themes nil))

    (let ((h/material/themes #s(hash-table
                                size 8
                                test equal
                                data
                                ("dark" material
                                 "light" material-light)))
          (h/material/default "dark"))
      (setq-default h/material/theme (gethash (or (getenv "EMACS_MATERIAL_THEME") h/material/default)
                                              h/material/themes nil)))

    (load-theme h/material/theme h/trust-themes)))

(if (getenv "EMACS_LINUM")
    ;; http://is.gd/Mw5KiS
    (global-linum-mode t))

(defvar h-font-height)
(if (getenv "RETINA_DISPLAY")
    (setq h-font-height 170)
  (setq h-font-height 100))

;; TODO: Support different fonts
(unless (getenv "EMACS_NO_HACK_FONT")
  ;; Hack - http://sourcefoundry.org/hack/
  (if (or (file-exists-p (concat (getenv "HOME") "/.fonts/Hack-Regular.ttf"))
          (file-exists-p "/usr/share/fonts/TTF/Hack-Regular.ttf"))
      (set-face-attribute 'default nil
                          :family "Hack"
                          :height h-font-height
                          :weight 'normal)))

(unless (getenv "EMACS_NO_NOTO_EMOJI")
  ;; I don't work on macOS much anymore.. but if i do:
  ;; (set-fontset-font t 'symbol (font-spec :family "Apple Color Emoji") (selected-frame) 'prepend)
  ;; Emoji font
  (set-fontset-font t 'symbol (font-spec :family "Noto Emoji") (selected-frame) 'prepend))

;; TODO: Make the below things toggle-able

(display-time-mode)

;; https://www.emacswiki.org/emacs/HighlightCurrentLine
(global-hl-line-mode t)

;; No toolbar, please.
(tool-bar-mode -1)

;; Or menu bar...
(menu-bar-mode -1)

;; Or scroll bar.
(scroll-bar-mode -1)

;; Maximize Emacs when it's opened
(add-to-list 'default-frame-alist '(fullscreen . maximized))

;;; ui.el ends here