summary refs log tree commit diff stats
path: root/init.el
blob: eae172a9a80e191794253b74e2839450e1217105 (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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
;;; init.el ~ acdw -*- lexical-binding: t -*-

;;; emacs configuration - general

(use-package emacs
  :init
  (setq calendar-location-name "Baton Rouge, LA")
  (setq calendar-latitude 30.39)
  (setq calendar-longitude -91.83)

  (setq browse-url-browser-function 'browse-url-generic)
  (setq  browse-url-generic-program "firefox"))

(use-package auth-source
  :init
  (setq auth-sources '("~/.authinfo")) ;; TODO: gpg
  (setq user-full-name "Case Duckworth")
  (setq user-mail-address "acdw@acdw.net"))

(use-package better-defaults
  :config ; add other "better defaults" of my own
  (when acdw/at-larry
    (setq visible-bell nil))

  (setq version-control t)
  (setq delete-old-versions t)
  (setq kept-new-versions 6)
  (setq kept-old-versions 4)
  (setq create-lockfiles nil)
  (setq auto-save-file-name-transforms
        `((".*" ,(concat user-emacs-directory "backups/") t)))
  (auto-save-mode)

  (defun full-auto-save ()
    (interactive)
    (save-excursion
      (dolist (buf (buffer-list))
        (set-buffer buf)
        (if (and (buffer-file-name) (buffer-modified-p))
            (basic-save-buffer)))))
  (add-hook 'auto-save-hook 'full-auto-save)
  (add-hook 'focus-out-hook 'full-auto-save) ; might be resource-intensive

  ;; follow the split!
  (defun split-and-follow-below ()
    (interactive)
    (split-window-below)
    (balance-windows)
    (other-window 1))

  (defun split-and-follow-right ()
    (interactive)
    (split-window-right)
    (balance-windows)
    (other-window 1))

  (setq save-place-file
        (expand-file-name "places" user-emacs-directory))
  (save-place-mode)

  (set-language-environment "UTF-8")
  (prefer-coding-system 'utf-8)
  (set-default-coding-systems 'utf-8)
  (set-terminal-coding-system 'utf-8)
  (set-keyboard-coding-system 'utf-8)
  (setq default-buffer-file-coding-system 'utf-8)

  (fset 'yes-or-no-p 'y-or-n-p)

  (global-visual-line-mode)
  (mouse-avoidance-mode 'jump)
  (setq show-paren-style 'mixed)

  ;; TODO figure out how to add this to the :hook block
  (add-hook 'prog-mode-hook (if (and (fboundp 'display-line-numbers-mode)
				     (display-graphic-p))
				#'display-line-numbers-mode
			      #'linum-mode))

  (setq completion-ignore-case t)
  (setq read-buffer-completion-ignore-case t)
  (setq read-file-name-completion-ignore-case t)

  ;; don't confirm death
  (setq confirm-kill-processes nil)
  (setq confirm-kill-emacs nil)

  ;; cursor betterment
  (blink-cursor-mode 0)
  (setq cursor-type 'bar)

  :bind
  ([remap split-window-below] . split-and-follow-below)
  ([remap split-window-right] . split-and-follow-right)

  :hook
  (auto-save-hook . full-auto-save)
  (focus-out-hook . full-auto-save)
  (before-save-hook . delete-trailing-whitespace))

(use-package auto-compile
  :config
  (auto-compile-on-load-mode)
  (setq load-prefer-newer t))

;; start the server when at home

(if (not acdw/at-work)
    (server-start))

;;; quality-of-life improvements

(use-package diminish)

(use-package which-key
  :diminish which-key-mode
  :config
  (which-key-mode))

(use-package recentf
  :init
  (setq recentf-max-menu-items 100)
  (setq recentf-max-saved-items 100)
  :config
  (recentf-mode))

(use-package savehist
  :config
  (savehist-mode))

(use-package restart-emacs)

(use-package ivy
  :init
  (setq ivy-use-virtual-buffers t)
  (setq ivy-wrap t)
  (setq ivy-count-format "(%d/%d) ")
  (setq enable-recursive-minibuffers t)
  (setq ivy-re-builders-alist
        '((read-file-name-internal . ivy--regex-fuzzy)
          (t . ivy--regex-plus)))
  :bind
  ("C-x b" . ivy-switch-buffer)
  ("C-c v" . ivy-push-view)
  ("C-c V" . ivy-pop-view)
  ("C-c C-r" . ivy-resume)
  :config
  (ivy-mode))

(use-package swiper
  :bind
  ("C-s" . swiper-isearch))

(use-package counsel ; includes ivy, counsel, swiper
  :bind
  ("M-x" . counsel-M-x)
  ("C-x C-f" . counsel-find-file)
  ("M-y" . counsel-yank-pop)
  ("<f1> f" . counsel-describe-function)
  ("<f1> v" . counsel-describe-variable)
  ("<f1> l" . counsel-find-library)
  ("<f2> i" . counsel-info-lookup-symbol)
  ("<f2> u" . counsel-unicode-char)
  ("<f2> j" . counsel-set-variable)
  ("C-c c" . counsel-compile)
  ("C-c g" . counsel-git)
  ("C-c j" . counsel-git-grep)
  ("C-c L" . counsel-git-log)
  ("C-c k" . counsel-rg)
  ("C-c m" . counsel-linux-app)
  ("C-c n" . counsel-fzf)
  ("C-x l" . counsel-locate)
  ("C-c J" . counsel-file-jump)
  ("C-S-o" . counsel-rhythmbox)
  ("C-c w" . counsel-wmctrl)
  ("C-c b" . counsel-bookmark)
  ("C-c d" . counsel-descbinds)
  ("C-c g" . counsel-git)
  ("C-c o" . counsel-outline)
  ("C-c t" . counsel-load-theme)
  ("C-c F" . counsel-org-file))

(use-package ivy-rich
  :after ivy
  :config
  (ivy-rich-mode)
  (setcdr (assq t ivy-format-functions-alist)
          #'ivy-format-function-line))

(use-package avy
  :bind
  ("M-s" . avy-goto-char-timer)
  :config
  (use-package ivy-avy))

;;; programming

(use-package aggressive-indent
  :diminish aggressive-indent-mode
  :hook
  (prog-mode-hook . aggressive-indent-mode))

(use-package magit
  :if (not acdw/at-work)
  :bind
  ("C-x g" . magit))

(use-package forge
  :if (not acdw/at-work)
  :after magit
  :custom
  (forge-owned-accounts '(("duckwork"))))

(use-package company
  :commands company-mode
  :init
  (setq company-idle-delay 0.1)
  :hook
  (prog-mode-hook . company-mode)
  :bind (:map company-active-map
              ("C-n" . company-select-next)
              ("C-p" . company-select-previous))
  :config
  (use-package company-quickhelp
    :hook
    (company-mode . (lambda ()
                      (company-quickhelp-local-mode)))))

(use-package helpful
  :bind
  ("C-h f" . helpful-callable)
  ("C-h v" . helpful-variable)
  ("C-h k" . helpful-key)
  ("C-c C-d" . helpful-at-point)
  ("C-h F" . helpful-function)
  ("C-h C" . helpful-command)
  :custom
  (counsel-describe-function-function #'helpful-callable)
  (counsel-describe-variable-function #'helpful-variable))

(unless acdw/at-work
  (use-package su
    :config
    (su-mode))

  (use-package trashed
    :init
    (setq delete-by-moving-to-trash t)))

;;; writing

(use-package visual-fill-column
  :init
  (setq split-window-preferred-function 'visual-fill-column-split-window-sensibly)
  (setq visual-fill-column-center-text t)
  :config
  (advice-add 'text-scale-adjust
              :after #'visual-fill-column-adjust))

;;; window management

(use-package switch-window
  :init
  (setq switch-window-shortcut-style 'qwerty)
  :bind
  ([remap other-window] . switch-window)
  ("s-o" . switch-window))

;;; theming and looks

(use-package doom-modeline
  :init
  (setq doom-modeline-icon nil)
  (setq doom-modeline-enable-word-count t)
  (when acdw/at-larry
    (setq display-time-format "%R")
    (display-time-mode))
  :config
  (doom-modeline-mode))

(when acdw/at-larry
  (use-package statusbar
    :straight (statusbar
               :host github
               :repo "dakra/statusbar.el")
    :hook
    (exwm-init-hook . statusbar-mode)))

;; modus themes

(use-package modus-operandi-theme
  :if window-system
  :config
  (load-theme 'modus-operandi t t)

  (defun acdw/sunrise ()
    (enable-theme 'modus-operandi)
    (start-process-shell-command "light" nil "light -S 60"))

  (if acdw/at-work
      (enable-theme 'modus-operandi)
    (run-at-time (nth 1 (split-string (sunrise-sunset)))
                 (* 60 60 24) #'acdw/sunrise)))

(unless acdw/at-work
  (use-package modus-vivendi-theme
    :if window-system
    :config
    (load-theme 'modus-vivendi t t)

    (defun acdw/sunset ()
      (enable-theme 'modus-vivendi)
      (start-process-shell-command "light" nil "light -S 35"))

    (run-at-time (nth 4 (split-string (sunrise-sunset)))
                 (* 60 60 24) #'acdw/sunset)
    (run-at-time "12am" (* 60 60 24) #'acdw/sunset)))

;;; gemini/gopher
(use-package elpher
  :straight (elpher
	     :repo "git://thelambdalab.xyz/elpher.git")
  :bind (:map elpher-mode-map
	      ("n" . 'elpher-next-link)
	      ("p" . 'elpher-prev-link)))

(use-package gemini-mode
  :straight (gemini-mode
	     :repo "https://git.carcosa.net/jmcbray/gemini.el.git"))

(use-package gemini-write
  :straight (gemini-write
	     :repo "https://alexschroeder.ch/cgit/gemini-write"))

;;; exwm ~ Emacs X Window Manager
(when acdw/at-larry
  (use-package exwm
    :if window-system
    :demand
    :custom
    (exwm-layout-show-all-buffers t)
    (exwm-workspace-warp-cursor t)
    ;;(mouse-autoselect-window t)
    (exwm-workspace-number 4)
    (exwm-input-global-keys
     `(
       ([?\s-r] . exwm-reset)
       ([?\s-w] . exwm-workspace-switch)
       ([?\s-&] . (lambda (command)
		    (interactive (list (read-shell-command "$ ")))
		    (start-process-shell-command command nil command)))
       ,@(mapcar (lambda (i)
		   `(,(kbd (format "s-%d" i)) .
		     (lambda ()
		       (interactive)
		       (exwm-workspace-switch-create ,i))))
	         (number-sequence 0 9))))
    (exwm-input-simulation-keys
     '(([?\C-b] . [left])
       ([?\M-b] . [C-left])
       ([?\C-f] . [right])
       ([?\M-f] . [C-right])
       ([?\C-p] . [up])
       ([?\C-n] . [down])
       ([?\C-a] . [home])
       ([?\C-e] . [end])
       ([?\M-v] . [prior])
       ([?\C-v] . [next])
       ([?\C-d] . [delete])
       ([?\C-k] . [S-end delete])
       ([?\C-s] . [?\C-f])
       ([?\C-w] . [?\C-x])
       ([?\M-w] . [?\C-c])
       ([?\C-y] . [?\C-v])))
    :hook
    ((exwm-update-class-hook .
			     (lambda () "Rename buffer to window's class name"
			       (exwm-workspace-rename-buffer exwm-class-name)))
     (exwm-update-title-hook .
			     (lambda () "Update workspace name to window title"
			       (when (not exwm-instance-name)
			         (exwm-workspace-rename-buffer exwm-title))))
     (exwm-init-hook . window-divider-mode)
     (exwm-init-hook .
		     (lambda () "Autostart"
		       (start-process-shell-command "cmst" nil "cmst -m -w 5")
		       (start-process-shell-command "keepassxc" nil "keepassxc")
		       (start-process-shell-command
		        "pa-applet" nil
		        "pa-applet --disable-key-grabbing --disable-notifications")
		       (start-process-shell-command
                        "cbatticon" nil "cbatticon"))))
    :config
    (require 'exwm)
    (exwm-enable)
    (require 'exwm-systemtray)
    (exwm-systemtray-enable))

  (use-package exwm-firefox-core
    :after exwm
    :straight (exwm-firefox-core
 	       :type git
 	       :host github
 	       :repo "walseb/exwm-firefox-core"))

  (use-package exwm-firefox
    :after exwm-firefox-core
    :straight (exwm-firefox
 	       :type git
 	       :host github
 	       :repo "ieure/exwm-firefox")
    :config
    (exwm-firefox-mode))

  (use-package exwm-mff
    :straight (:repo "duckwork/exwm-mff")
    :after exwm
    :hook
    (exwm-init-hook . exwm-mff-mode))
  ) ;; end of acdw/at-larry block