summaryrefslogtreecommitdiff
path: root/emacs/.config/doom-staging/config.el
blob: 34e66b51e5e2954c663398c660bbddbc1658cebe (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
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-

;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!

;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "KJ Orbekk"
      user-mail-address "kj@orbekk.com")

(defmacro system-specific-config (system-regex &rest code)
  "Run CODE on systems that match SYSTEM-REGEX."
  `(when (string-match ,system-regex (system-name))
     ,@code))

(setq kj/font-size 16)
(setq doom-theme 'modus-operandi)
(after! modus-themes
  (modus-themes-load-themes))

;; Completion gets in the way more often than being useful.
(setq company-idle-delay nil)
(setq lsp-ui-doc-enable nil)

(setq display-line-numbers-type nil)

;; Scratch buffers are often for lisp stuff.
(setq doom-scratch-initial-major-mode 'lisp-interaction-mode)

(setq math-additional-units
      '((ZiB "1024 * EiB" "Zebibyte")
        (EiB "1024 * PiB" "Exbibyte")
        (PiB "1024 * TiB" "Pebibyte")
        (TiB "1024 * GiB" "Tebibyte")
        (GiB "1024 * MiB" "Gibibyte")
        (MiB "1024 * KiB" "Mebibyte")
        (KiB "1024 * B" "Kibibyte")
        (B nil "Byte")
        (Zib "1024 * ZiB" "Zebibit")
        (Eib "1024 * PiB" "Exbibit")
        (Pib "1024 * TiB" "Pebibit")
        (Tib "1024 * GiB" "Tebibit")
        (Gib "1024 * Mib" "Gibibit")
        (Mib "1024 * Kib" "Mebibit")
        (Kib "1024 * b" "Kibibit")
        (b "B / 8" "Bit")))

(system-specific-config
 "pincer"
 (setq kj/font-size 18)
 (setq doom-theme 'doom-one))

(system-specific-config
 "orbekk"
 (setq doom-theme 'doom-solarized-light))

(system-specific-config
 "^siofra\."
 (setq kj/font-size 20)
 (setq doom-theme 'doom-one-light))

(setq doom-font (font-spec :family "iosevka" :size kj/font-size))
(setq doom-variable-pitch-font (font-spec :family "Noto Serif" :size kj/font-size))

;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")
(setq org-todo-keywords
      '((sequence
         "TODO(t)" "ACTIVE(a!)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))
(setq org-refile-use-outline-path nil)
(setq org-refile-targets '((nil . (:maxlevel . 2))))
(setq org-log-into-drawer t)
(setq org-agenda-log-mode-items '(closed clock state))
(setq org-agenda-start-day nil)
(setq org-agenda-block-separator nil)
(setq org-agenda-compact-blocks t)
(setq org-agenda-start-with-log-mode nil)
(setq org-habit-show-all-today t)
(setq org-agenda-time-grid '((daily today require-timed) (800 1600) "......" "----------------------"))
(setq org-roam-directory (concat org-directory "roam/"))
(setq-default org-agenda-files '())
(dolist (file '("tasks.org"
                "running-2022.org"))
  (add-to-list 'org-agenda-files (concat org-roam-directory file)))
(setq org-roam-db-location (concat org-roam-directory "/org-roam.db"))
(setq org-export-with-toc nil)
(setq deft-directory org-directory)
(setq deft-recursive t)
;; Org html export
(setq org-html-htmlize-output-type 'css)
;; Website publish settings.
(defvar kj/publish-tag "publish")
(defvar kj/publish-directory "/ssh:orbekk@dragon.orbekk.com:/storage/srv/kj.orbekk.com")
(add-to-list 'org-modules 'org-habit)

; (setq org-appear-autolinks t)
; (use-package! org-appear
;   :hook (org-mode . org-appear-mode))

(setq org-log-done 'time)
(setq org-todo-keywords
      '((sequence
         "TODO(t)"  ; A task that needs doing & is ready to do
         "PROJ(p)"  ; A project, which usually contains other tasks
         "LOOP(r)"  ; A recurring task
         "STRT(s)"  ; A task that is in progress
         "WAIT(w)"  ; Something external is holding up this task
         "HOLD(h)"  ; This task is paused/on hold because of me
         "IDEA(i)"  ; An unconfirmed and unapproved task or notion
         "|"
         "DONE(d!)"  ; Task successfully completed
         "KILL(k)") ; Task was cancelled, aborted or is no longer applicable
        (sequence
         "[ ](T)"   ; A task that needs doing
         "[-](S)"   ; Task is in progress
         "[?](W)"   ; Task is being held up or paused
         "|"
         "[X](D)")  ; Task was completed
        (sequence
         "|"
         "OKAY(o)"
         "YES(y)"
         "NO(n)")))

;;(use-package! org-super-agenda
;;  :after org-agenda
;;  :init
;;
;;  (setq org-agenda-custom-commands
;;        '(("d" "Daily KJ agenda"
;;           ((agenda "" ((org-agenda-span 'day)
;;                        (org-agenda-start-day nil)
;;                        (org-super-agenda-groups
;;                         '((:name "Habits"
;;                            :habit t
;;                            :order 2)
;;                           (:name "Past & Overdue"
;;                            :scheduled past
;;                            :deadline past)
;;                           (:name "Today"
;;                            :time-grid t
;;                            :date today)
;;                           (:name "Due Soon"
;;                            :scheduled future
;;                            :deadline future)))))
;;            (alltodo "" ((org-agenda-overriding-header "")
;;                         (org-super-agenda-groups
;;                          '((:name "Important"
;;                             :priority "A"
;;                             :priority "B")
;;                            (:discard (:habit t))))))))))
;;
;;  :config
;;  (org-super-agenda-mode 1))

(setq org-journal-file-type 'weekly)
(setq org-journal-dir org-roam-directory)
(setq org-journal-file-format "journal-%Y-%m-%d.org")
(setq org-journal-enable-agenda-integration t)
(defun kj/org-journal-init ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (org-id-get-create)
    (org-set-property "category" "journal")))

(defun kj/org-journal-file-header (time)
  (format-time-string "#+title: Week of %F (%W)\n"
                      (org-journal--convert-time-to-file-type-time time)))
(setq org-journal-file-header #'kj/org-journal-file-header)
(add-hook 'org-journal-after-header-create-hook 'kj/org-journal-init)

;; Allow more keys when navigating with avy.
(setq avy-keys '(?a ?o ?e ?u ?d ?h ?n ?s ?l ?, ?. ?p ?r))
(setq avy-timeout-seconds 0.4)

;; Low menu delay.
(setq which-key-idle-delay .5)

;; Allow longer output in compilation buffer.
(setq comint-buffer-maximum-size 10000)

;; Replace values in an alist from a list of replacements.
;;
;; Example:
;;   (kj/assq-replace '((:a . 1)) '((:a . 2)))
(defun kj/assq-replace (replacements alist)
  (let ((replace1 (lambda (aelem alist)
                    (cons aelem (assq-delete-all (car aelem) alist)))))
    (if replacements
        (kj/assq-replace (cdr replacements)
                         (funcall replace1 (car replacements) alist))
      alist)))

(server-start)
(remove-hook 'doom-first-buffer-hook #'smartparens-global-mode)
(add-to-list 'auto-mode-alist '("\\.journal\\'" . ledger-mode))

;; Make ace window more visible
(custom-set-faces!
  '(aw-leading-char-face
    :foreground "white" :background "red"
    :weight bold :height 2.5 :box (:line-width 10 :color "red")))

(after! racket-mode
  (remove-hook! 'racket-mode #'racket-smart-open-bracket-mode))

(after! org
  (add-hook 'org-mode-hook 'mixed-pitch-mode)
  (setq org-roam-mode-section-functions
        (list #'org-roam-backlinks-section
              #'org-roam-reflinks-section
              #'org-roam-unlinked-references-section))

  (add-to-list 'org-structure-template-alist
               '("se" . "src emacs-lisp"))

  (setq org-babel-default-header-args
        (kj/assq-replace '((:exports . "both")
                           (:eval . "never-export")
                           (:output-dir . "static/data/"))
                         org-babel-default-header-args))

  (defun kj/org-journal-find-location ()
    ;; Open today's journal, but specify a non-nil prefix argument in order to
    ;; inhibit inserting the heading; org-capture will insert the heading.
    (org-journal-new-entry t))
  ;; (unless (eq org-journal-file-type 'daily)
  ;;   (org-narrow-to-subtree))
  ;; (goto-char (point-max)))

  (defun kj/org-journal-narrowed-location ()
    ;; Open today's journal, but specify a non-nil prefix argument in order to
    ;; inhibit inserting the heading; org-capture will insert the heading.
    (org-journal-new-entry t)
    (unless (eq org-journal-file-type 'daily)
      (org-narrow-to-subtree))
    (goto-char (point-max)))

  (setq org-capture-templates
        `(("g" "Go to current journal entry" plain (function kj/org-journal-find-location)
           "%i%?" :jump-to-captured t :immediate-finish t)
          ("t" "Create a TODO" entry (file+headline "~/org/roam/tasks.org" "Inbox")
           "** TODO %?\n%i\n%a")
          ("w" "Log bodyweight" table-line
           (file+headline ,(concat org-roam-directory "bodyweight.org")
                          "Body weight log")
           "| %t | %^{Weight} | |"
           :prepend t :immediate-finish t)))

  (defun kj/find-agenda-files-containing-tag (tag)
    (setq org-agenda-archives-mode nil)
    (let* ((org-agenda-archives-mode nil)
           (candidates (org-agenda-files nil 'ifmode))
           (matcher (cdr (org-make-tags-matcher tag)))
           (files))
      ;; (message "Results:")
      (dolist (file candidates files)
        (org-check-agenda-file file)
        (with-current-buffer (org-get-agenda-file-buffer file)
          ;; (message "%S" (org-scan-tags 'agenda matcher nil))
          (when (org-scan-tags 'agenda matcher nil)
            (push file files))))))

  (setq kj/inbox-path "/ssh:dragon.orbekk.com:/storage/srv/kj.orbekk.com/dav/Inbox.org")

  (defun kj/fetch-inbox ()
    (interactive)
    (let ((content (with-current-buffer (find-file-noselect kj/inbox-path)
                     (buffer-string))))
      (kj/org-journal-find-location)
      (when (not (string-empty-p content))
        (org-paste-subtree nil content)))
    (with-current-buffer (find-file-noselect kj/inbox-path)
      (erase-buffer)
      (save-buffer)
      (kill-buffer)))

  (defvar org-publish-project-alist)
  (defun kj/org-publish (&optional project force)
    (interactive)
    (setq project (or project "all"))
    (setq force (or force current-prefix-arg))
    (setq org-agenda-files (list org-roam-directory))
    (let* ((static-files-re (string-join '("css" "txt" "jpg" "png" "gif" "svg") "\\|"))
           (files-to-include (kj/find-agenda-files-containing-tag kj/publish-tag))
           ;; Disable org babel exports during publish entirely to speed up publish.
           ;; This messes up babel output handling.
           ;; (org-export-use-babel nil)
           (org-babel-default-header-args
            (kj/assq-replace '((:exports . "both")
                               (:eval . "never-export"))
                             org-babel-default-header-args))
           (org-publish-project-alist
            `(
              ("static"
               :base-directory ,(concat org-roam-directory "/static")
               :base-extension ,static-files-re
               :recursive t
               :publishing-directory ,(concat kj/publish-directory "/static")
               :publishing-function org-publish-attachment)
              ("source"
               :base-directory ,org-roam-directory
               :base-extension "org"
               :exclude ".*"
               :include ,files-to-include
               :recursive t
               :publishing-directory ,kj/publish-directory
               :publishing-function org-publish-attachment)
              ("html"
               :base-directory ,org-roam-directory
               :base-extension "org"
               :recursive t
               :exclude ".*"
               :include ,files-to-include
               :publishing-directory ,kj/publish-directory
               :publishing-function org-html-publish-to-html

               :with-broken-links t
               :with-toc nil
               :with-latex t
               :with-drawers t
               :with-title t
               :section-numbers nil

               ;; HTML options
               :html-toplevel-hlevel 2
               :html-preamble ""
               :html-postamble ""
               :html-html5-fancy t
               :html-doctype "html5"
               :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"static/org.css\"/>"
               :html-head-include-scripts nil
               :html-head-include-default-style nil
               :html-container article)

              ("all" :components ("static" "source" "html")))))

      (org-publish project force))))

(setq aw-dispatch-always t)

;;; Keybindings
(map! (:after evil-org
       :leader "n P" #'kj/org-publish)

      (:leader
       :desc "window" "e" evil-window-map)

      (:map evil-window-map
       "e" #'ace-window))

(add-hook 'eshell-mode-hook
          (lambda ()
            (setenv "PAGER" "cat"))
          (setenv "EDITOR" "emacsclient"))

(after! evil-embrace
  (evil-embrace-enable-evil-surround-integration)
  (setq evil-embrace-show-help-p t))

(let ((local-config "~/.doom.d/config.local.el"))
  (when (file-exists-p local-config)
    (load-file local-config)))