summary refs log tree commit diff stats
path: root/init.el
blob: 3049c366838039cbb99e457bb514a5f944787028 (plain) (blame)
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
;; load path
(add-to-list 'load-path "~/.emacs.d/lisp")

;; function to create a file if it doesn't already exist
(defun ooo/create-if-not-exist (filename)
  (interactive)
  (if (not(file-exists-p filename))
      (with-temp-file filename
        (insert ""))))

;; Prevent emacs from adding stuff to init.el
;; Instead, add that stuff to custom.el
(ooo/create-if-not-exist "~/.emacs.d/lisp/custom.el")
(setq custom-file
    (expand-file-name "~/.emacs.d/lisp/custom.el" user-emacs-directory))
(load custom-file)

;; Who am I -- probably modify this bit if you aren't me.
(setq user-full-name "Eli Mellen"
      user-mail-address "hi@eli.li")

;; I find automated backups to be wicked useful. I allow emacs to make many of them, 
;; and to make them often. This said, I don't like them muddying my project directories, 
;; so I have them dumped into a common folder.
(setq backup-directory-alist `(("." . "~/.saves")))
(setq backup-by-copying t) ;; SLOW but very safe
(setq delete-old-versions t
    kept-new-versions 6
    kept-old-versions 2
    version-control t)

;; Likewise, history can be a valuable resource. 
;; See, https://www.wisdomandwonder.com/wp-content/uploads/2014/03/C3F.html for more on this.
(setq savehist-file "~/.emacs.d/savehist")
(savehist-mode 1)
(setq history-length t)
(setq history-delete-duplicates t)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
      '(kill-ring
        search-ring
        regexp-search-ring))

;; Make the default scratch buffer an org-mode one
(setq initial-major-mode 'org-mode)

;; UI stuffs
(setq frame-title-format '("%b")
      ring-bell-function 'ignore
      default-directory "~/")

(tool-bar-mode   -1)
(menu-bar-mode   -1)
(scroll-bar-mode -1)
(window-divider-mode 1) ; allows you to resize windows by grabbing the divider
(global-visual-line-mode 1) ; line wrapping, because I spend a lot of time working on very tiny screens
(global-prettify-symbols-mode 1)
(column-number-mode +1)
(global-hl-line-mode 1) ; highlight the currently active line

;; Display line numbers, but only on Emacs26 or higher
(when (version<= "26.0.50" emacs-version )
  (global-display-line-numbers-mode))

;; Play nice(er) with the X11 clipboard
(setq select-enable-clipboard t)

;; No thank you to a welcome screen
(setq inhibit-startup-message t initial-scratch-message nil)

;; Automatically save and load changes
(global-auto-revert-mode +1)
(auto-save-visited-mode  +1)

;; Automatically insert buddies
(electric-pair-mode +1)

;; Highlight buddies (and do it right away)
(setq show-paren-delay 0)
(show-paren-mode 1)

;; Increase line space for better readability
(setq-default line-spacing 3)

(setq-default indent-tabs-mode nil
              tab-width 2)

;; ===== SIMPLE THEME =====

(set-face-font 'default "Go Mono 14")

; (set-frame-parameter (selected-frame)
;                      'internal-border-width 24)
; (setq default-frame-alist
;       (append (list '(width  . 72) '(height . 40)
;                     '(vertical-scroll-bars . nil)
;                     '(internal-border-width . 24)
;                     '(font . "Go Mono 14"))))


;; Underline line at descent position, not baseline position
(setq x-underline-at-descent-line t)

;; No ugly button for checkboxes
(setq widget-image-enable nil)

;; Line cursor and no blink
(set-default 'cursor-type  '(bar . 1))
(blink-cursor-mode 1)

;; No sound
(setq visible-bell t)
(setq ring-bell-function 'ignore)

;; Fringe or bangs?
(fringe-mode '(0 . 0))
(defface fallback '((t :family "Go Mono"
                       :inherit 'face-faded)) "Fallback")
(set-display-table-slot standard-display-table 'truncation
                        (make-glyph-code ?… 'fallback))
(set-display-table-slot standard-display-table 'wrap
                        (make-glyph-code ?↩ 'fallback))

;; Vertical window divider
(setq window-divider-default-right-width 3)
(setq window-divider-default-places 'right-only)
(window-divider-mode)

(setq-default left-fringe-width 1 right-fringe-width 8
              left-margin-width 1 right-margin-width 0)

;; ===== PACKAGES =====

;; bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; go go gadget straight.el
(setq package-enable-at-startup nil)

;; make it pretend to be use-package
(straight-use-package 'use-package)

;; theme
(straight-use-package 'acme-theme)
(load-theme 'acme t)
;; this makes it so that emacs doesn't load a theme when launched in a terminal
(add-to-list 'default-frame-alist '(tty-color-mode  . -1))

;; whimsy
(straight-use-package 'rainbow-delimiters)
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
(straight-use-package 'nyan-mode)
(add-hook 'prog-mode-hook #'nyan-mode)
(straight-use-package 'emojify)
(add-hook 'after-init-hook #'global-emojify-mode)

;; git
(straight-use-package 'magit)
; (straight-use-package 'git-gutter)
; (add-hook 'prog-mode-hook #'global-git-gutter-mode)

;; keep splits good sizes
(straight-use-package 'golden-ratio)
(golden-ratio-mode 1)

;; ergonomic stuff for easy cheating and nicer mode-line
(straight-use-package 'helm)
(setq helm-M-x-fuzzy-match t
    helm-mode-fuzzy-match t
    helm-buffers-fuzzy-matching t
    helm-recentf-fuzzy-match t
    helm-locate-fuzzy-match t
    helm-semantic-fuzzy-match t
    helm-imenu-fuzzy-match t
    helm-completion-in-region-fuzzy-match t
    helm-candidate-number-list 150
    helm-split-window-in-side-p t
    helm-move-to-line-cycle-in-source t
    helm-echo-input-in-header-line t
    helm-autoresize-max-height 0
    helm-autoresize-min-height 20)
:config (helm-mode 1)
(global-set-key (kbd "M-x") 'helm-M-x) ; like spacemacs, but with M-x instead of SPC
(global-set-key (kbd "M-f") 'helm-find-files)

(straight-use-package 'which-key)
(setq which-key-separator " ")
(setq which-key-prefix-prefix "+")

(straight-use-package 'company)
(setq company-dabbrev-downcase 0 company-idle-delay 0) 
(progn (company-mode +1)
  (global-company-mode +1))

;; ===== org-mode =====

(straight-use-package 'org)
(setq org-todo-keywords
      '((sequence "TODO(t)" "|" "DONE(d)") ;; basic boolean todo lists
        (sequence "BACKLOG" "NEXT" "DOING" "FOLLOW-UP" "BLOCKED" "|" "DONE" "DELEGATED"))) ;; fancy-pants kanban style, multi-state todo lists
      (setq org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("hobby" . ?h) ("client" . ?c))) ;; not in use, but one day...
      (setq org-fontify-done-headline t)
      (custom-set-faces
      '(org-done ((t (:foreground "#5DA7AA" :weight normal :strike-through t))))
      '(org-headline-done
            ((((class color) (min-colors 16) (background light))
              (:foreground "#5E81AC" :strike-through t)))))

(setq org-capture-templates
      '(("t" "todo" entry (file+headline "~/Dropbox/Eli/org/todo.org" "Tasks")
         "* TODO %?\n  %i\n  %a")
        ("s" "scratch" entry (file+datetree "~/Dropbox/Eli/org/scratch.org")
         "* %?\nEntered on %U\n  %i\n  %a")
        ("i" "inbox" entry (file+datetree "~/Dropbox/Eli/org/inbox.org")
         "* %?\nEntered on %U\n %i\n %a")))

(straight-use-package 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))

;; Export org files in various formats
(straight-use-package 'htmlize)
(straight-use-package 'ox-pandoc)

(straight-use-package 'restclient)

(straight-use-package 'ob-restclient)
(org-babel-do-load-languages
 'org-babel-load-languages
 '((restclient . t)))

;; ORG BABEL
(org-babel-do-load-languages
 'org-babel-load-languages
 '((shell . t)
   (emacs-lisp . t)
   (forth . t)
   (C . t)
   (sqlite . t)
   (restclient . t)))

(defun org-babel-tangle-block()
  (interactive)
  (let ((current-prefix-arg '(4)))
     (call-interactively 'org-babel-tangle)))

(eval-after-load "org"
  '(progn
     (define-key org-mode-map (kbd "C-c b") 'org-babel-tangle-block)))

(eval-after-load 'org
      (lambda()
        (require 'ob-emacs-lisp)
        (require 'ob-sql)
        (require 'ob-shell)
        (require 'ob-sqlite)
        (require 'ob-org)
        (require 'ob-css)
        (require 'ob-C)
        (require 'ob-forth)
        (require 'ob-lisp)
        (setq org-export-babel-evaluate nil)
        (setq org-startup-indented t)
        ;; increase imenu depth to include third level headings
        (setq org-imenu-depth 3)
        ;; Update images from babel code blocks automatically
        (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
        (setq org-src-fontify-natively t)
        (setq org-src-tab-acts-natively t)
        (setq org-confirm-babel-evaluate nil)))

;; ===== LANGUAGES =====

;; Common Lisp support
(straight-use-package 'sly)
(setq inferior-lisp-program "/opt/homebrew/bin/sbcl --noinform") ;; this is the bit that changes from machine to machine, usually.

;; Scheme support for chicken, chibi and racket (brev too!)...and guile
(straight-use-package 'geiser)
(setq geiser-racket-binary "/Applications/Racket\ v8.7/bin/racket")
(setq geiser-chicken-binary "/opt/homebrew/bin/csi")
(setq geiser-chibi-binary "/usr/local/bin/chibi-scheme")
(setq geiser-guile-binary "/opt/homebrew/bin/guile")
(setq geiser-active-implementations '(chibi chicken racket guile kawa gauche))
(setq geiser-repl-history-filename "~/.saves/geiser")
(straight-use-package 'geiser-chibi)
(straight-use-package 'geiser-chicken)
(straight-use-package 'geiser-racket)
(straight-use-package 'geiser-guile)
(straight-use-package 'geiser-kawa)
(straight-use-package 'geiser-gauche)
(add-to-list 'auto-mode-alist '("\\.brev$" . scheme-mode))

;; ELISP
;; use eldoc with elisp
(add-hook 'emacs-lisp-mode-hook #'eldoc-mode)

;; JANET
(straight-use-package 'janet-mode)

;; GO
(straight-use-package 'go-mode)

;; LUA
(straight-use-package 'lua-mode)

;; JAVASCRIPT
(straight-use-package 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

;; FENNEL
(straight-use-package 'fennel-mode)

;; RACKET
(straight-use-package 'racket-mode)
(straight-use-package 'pollen-mode)
(straight-use-package 'company-pollen)

;; FORTH
(autoload 'forth-mode "gforth.el")
(setq auto-mode-alist (cons '("\\.fs\\'" . forth-mode) 
			    auto-mode-alist))
(autoload 'forth-block-mode "gforth.el")

;; UXNTAL
(straight-use-package 'uxntal-mode)

;; FLYCHECK
(straight-use-package 'flycheck)
(global-flycheck-mode)
(straight-use-package 'exec-path-from-shell)
(exec-path-from-shell-initialize)
(add-hook 'after-init-hook #'global-flycheck-mode)
(setq-default flycheck-indication-mode 'left-margin)
(add-hook 'flycheck-mode-hook #'flycheck-set-indication-mode)

;; FLYSPELL
(dolist (hook '(text-mode-hook))
  (add-hook hook (lambda () (flyspell-mode 1))))

(dolist (hook '(change-log-mode-hook log-edit-mode-hook))
  (add-hook hook (lambda () (flyspell-mode -1))))

(eval-after-load "flyspell"
  '(progn
     (define-key flyspell-mouse-map [down-mouse-3] #'flyspell-correct-word)
     (define-key flyspell-mouse-map [mouse-3] #'undefined)))




;; Instruct emacs to check for personal-pizza.el
;; This file is used for one-off overrides and any
;; tweaks that need to be made to init.el rather than
;; editing the config directly. Should be loaded last,
;; or at least after straight has been bootstrapped and
;; loaded some other stuff.
(when (file-exists-p "~/.emacs.d/lisp/personal-pizza.el")
  (load "~/.emacs.d/lisp/personal-pizza.el"))



(provide 'init)