summaryrefslogtreecommitdiff
path: root/init.el
blob: cdd77b5ff766e015a946987513596f7ffa06fd69 (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
;;; init.el --- minimal single-file Org workflow -*- lexical-binding: t; -*-

;;; Code:

;; --------------------------------------------------
;; Core paths
;; --------------------------------------------------

(setq org-directory (expand-file-name "~/org"))
(setq org-default-notes-file (expand-file-name "obtf.org" org-directory))
(setq custom-file
  (expand-file-name "custom.el"
        (file-name-directory
         (or load-file-name user-init-file default-directory))))

;; --------------------------------------------------
;; Startup: agenda as modal view
;; --------------------------------------------------

(setq initial-buffer-choice
      (lambda ()
        (require 'org-agenda)
        (if org-agenda-files
            (progn
              (org-agenda nil "h")
              (current-buffer))
          (get-buffer-create "*scratch*"))))

;; --------------------------------------------------
;; Package bootstrap
;; --------------------------------------------------

(require 'package)

(setq package-archives
      '(("gnu"    . "https://elpa.gnu.org/packages/")
        ("nongnu" . "https://elpa.nongnu.org/nongnu/")
        ("melpa"  . "https://melpa.org/packages/")))

(package-initialize)

(dolist (pkg '(vertico marginalia orderless consult modus-themes olivetti))
  (unless (package-installed-p pkg)
    (unless package-archive-contents
      (package-refresh-contents))
    (package-install pkg)))

(require 'use-package)
(setq use-package-always-ensure t)

(use-package git-auto-commit-mode
  :pin melpa
  :commands (git-auto-commit-mode)
  :init
  (setq gac-shell-and
        (if (string-match-p "fish\\'" shell-file-name)
            " ; and "
          " && ")))

;; --------------------------------------------------
;; UI
;; --------------------------------------------------

(setq inhibit-startup-message t
      inhibit-startup-screen t
  auto-save-default nil
  backup-inhibited t
  compilation-ask-about-save nil
  echo-keystrokes 0.1
  enable-recursive-minibuffers t
  gc-cons-threshold (* 128 1024 1024)
  mouse-wheel-follow-mouse t
  mouse-wheel-progressive-speed nil
  mouse-wheel-scroll-amount '(1 ((shift) . 1))
  process-adaptive-read-buffering nil
  read-process-output-max (* 4 1024 1024)
  ring-bell-function #'ignore
  scroll-conservatively 101
  scroll-margin 2
  scroll-preserve-screen-position t
  scroll-step 1)

(column-number-mode 1)
(show-paren-mode 1)
(global-auto-revert-mode 1)
(delete-selection-mode 1)
(defalias 'yes-or-no-p 'y-or-n-p)

(setq-default abbrev-mode t
      fill-column 80
      indent-tabs-mode nil
      indicate-empty-lines t
      sentence-end-double-space nil
      tab-width 2)

(when (file-readable-p abbrev-file-name)
  (quietly-read-abbrev-file))

(when (display-graphic-p)
  (tool-bar-mode -1)
  (scroll-bar-mode -1)
  ;; Reapply the startup frame font to the selected GUI frame.
  (let ((font (alist-get 'font default-frame-alist)))
    (when font
      (set-face-attribute 'default t :font font))))

(use-package modus-themes
  :config
  (load-theme 'modus-vivendi t))

(use-package olivetti
  :bind (("C-c z" . olivetti-mode))
  :config
  (setq olivetti-body-width 100))

;; --------------------------------------------------
;; Completion
;; --------------------------------------------------

(use-package vertico
  :init (vertico-mode 1))

(use-package marginalia
  :init (marginalia-mode 1))

(use-package orderless
  :init
  (setq completion-styles '(orderless basic)))

(use-package consult
  :bind (("C-s" . consult-line)
         ("C-c o" . consult-outline)))

;; --------------------------------------------------
;; Org
;; --------------------------------------------------

(use-package org
  :ensure nil
  :bind (("C-c c" . org-capture)
         ("C-c a" . org-agenda)
         ("C-c r" . org-refile))
  :init
  (setq org-agenda-files
        (delq nil (list (and (file-exists-p org-default-notes-file)
                             org-default-notes-file)))
        org-agenda-custom-commands
        '(("h" "Home"
           ((agenda ""
                    ((org-agenda-overriding-header ":: THIS WEEK ::")))
            (todo "TODO"
                  ((org-agenda-overriding-header ":: TASKS ::")))
            (todo "CLARIFY"
                  ((org-agenda-overriding-header ":: OPEN QUESTIONS ::")))
            (tags "CATEGORY=\"inbox\"+LEVEL>1"
                  ((org-agenda-overriding-header ":: REFILE ::"))))))
        org-agenda-window-setup 'only-window
        org-startup-folded 'overview
        org-cycle-hide-drawer-startup t
        org-todo-keywords
        '((sequence "TODO" "CLARIFY" "|" "DONE"))
        org-use-speed-commands t
        org-refile-use-outline-path 'file
        org-outline-path-complete-in-steps nil
        org-refile-targets '((org-agenda-files :maxlevel . 2))
        org-id-link-to-org-use-id nil
        org-special-ctrl-a/e t
        org-insert-heading-respect-content t
        org-log-done 'time
        org-log-into-drawer t)

  :config
  ;; Keep capture modal in the current window.
  (add-to-list 'display-buffer-alist
           '("\\*Org Capture\\*" (display-buffer-reuse-window display-buffer-same-window)))

  (add-hook 'org-capture-mode-hook
            (lambda () (delete-other-windows))))

;; --------------------------------------------------
;; Capture templates
;; --------------------------------------------------

(setq org-capture-templates
      `(("i" "Inbox" entry
         (file+headline ,org-default-notes-file "Inbox")
     "* %?\n:PROPERTIES:\n:CAPTURED: %U\n:END:\n%a\n")

        ("t" "Task" entry
         (file+headline ,org-default-notes-file "Tasks")
     "* TODO %?\n:PROPERTIES:\n:CAPTURED: %U\n:END:\n%a\n")

        ("q" "Question" entry
         (file+headline ,org-default-notes-file "Questions")
     "* CLARIFY %?\n:PROPERTIES:\n:CAPTURED: %U\n:END:\n%a\n")

        ("m" "Meeting" entry
         (file+headline ,org-default-notes-file "Meetings")
         "* %<%H:%M> %?\n<%<%Y-%m-%d %a %H:%M>>\n")

        ("r" "Recurring" entry
         (file+headline ,org-default-notes-file "Recurring")
     "* TODO %?\n:PROPERTIES:\n:CAPTURED: %U\n:END:\nSCHEDULED: %^t\n")))

;; Load Custom state last so Customize values can override defaults above.
(load custom-file t)

(provide 'init)