summaryrefslogtreecommitdiffstats
path: root/lisp/init-org.el
blob: 4056dc442ddde35b58183a272a2b5e70c6e4a946 (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
(use-package org
  :ensure nil ;; package is bundled with emacs
  :bind (("C-c c" . org-capture)
         ("C-c a" . org-agenda)
         ("C-c l" . org-store-link)
         ("C-c f" . org-indent-region)
         ("C-c o a" . org-archive-subtree)
         ("C-c o s" . org-save-all-org-buffers))
  :config
  ;; file and tree where archived tasks should be moved
  (setq org-archive-location "%s_archive::* Archived Tasks")

  ;; save archive file when archiving
  (unless (version< org-version "9.4")
    (setq org-archive-subtree-save-file-p t))

  ;; sparse tree construction shows matches in archived trees
  (setq org-sparse-tree-open-archived-trees t)

  ;; display all org files in agenda
  (setq org-agenda-files (list org-directory))

  ;; refile targets 1 level in current buffer and all org agenda files
  (setq org-refile-targets '((nil :maxlevel . 2) (org-agenda-files :maxlevel . 1)))

  ;; record time when moving a task to done state
  (setq org-log-done 'time)

  ;; default file for capture
  (setq org-default-notes-file (expand-file-name "personal.org" org-directory))

  ;; capture template including title, date and time
  (setq org-capture-templates '(("p" "Personal" entry (file+olp "" "Tasks")
                                 "* TODO %?\n  %U"
                                 :prepend t
                                 :empty-lines-after 1)
                                ("w" "Work" entry (file+olp "work.org" "Tasks")
                                 "* TODO %?\n  %U"
                                 :prepend t
                                 :empty-lines-after 1)))

  ;; automatically mark archived entry as done
  (setq org-archive-mark-done t)

  ;; highlight code blocks
  (setq org-src-fontify-natively t)

  ;; indent code blocks the same way as the language major mode
  (setq org-src-tab-acts-natively t)

  ;; define todo states
  (setq org-todo-keywords '((sequence "TODO(t)" "WAIT(w)" "DONE(d)")))

  ;; disallow invisible edits
  (setq org-catch-invisible-edits 'error)

  ;; complete tags from all agenda files
  (setq org-complete-tags-always-offer-all-agenda-tags t)

  ;; search headlines via completion
  (setq org-goto-interface 'outline-path-completion)

  ;; include the full path when searching headlines
  (setq org-outline-path-complete-in-steps nil)

  ;; enable org-habit
  (unless (member 'org-habit org-modules)
          (add-to-list 'org-modules 'org-habit))

  ;; show habits on future days
  (setq org-habit-show-habits-only-for-today nil)

  ;; hide todo entries whose deadline is far away according to
  ;; org-deadline-warning-days
  (setq org-agenda-todo-ignore-deadlines 'far)

  ;; hide todo entries scheduled in the future
  (setq org-agenda-todo-ignore-scheduled 'future)

  ;; include two weeks in agenda
  (setq org-agenda-span 'fortnight)

  ;; customize agenda
  (setq org-agenda-custom-commands
        '(;; default view
          ("n" "Agenda and all TODOs" ((agenda "") (alltodo "")))
          ;; split by state
          ("m" "Agenda and all TODOs split by state"
           ((agenda "") (todo "TODO") (todo "WAIT"))))))

(provide 'init-org)