1 ;;; init-org.el --- Org-mode config -*- lexical-binding: t -*-
6 (maybe-require-package 'grab-mac-link
))
8 (maybe-require-package 'org-cliplink
)
10 (define-key global-map
(kbd "C-c l") 'org-store-link
)
11 (define-key global-map
(kbd "C-c a") 'org-agenda
)
13 (defvar sanityinc
/org-global-prefix-map
(make-sparse-keymap)
14 "A keymap for handy global access to org helpers, particularly clocking.")
16 (define-key sanityinc
/org-global-prefix-map
(kbd "j") 'org-clock-goto
)
17 (define-key sanityinc
/org-global-prefix-map
(kbd "l") 'org-clock-in-last
)
18 (define-key sanityinc
/org-global-prefix-map
(kbd "i") 'org-clock-in
)
19 (define-key sanityinc
/org-global-prefix-map
(kbd "o") 'org-clock-out
)
20 (define-key global-map
(kbd "C-c o") sanityinc
/org-global-prefix-map
)
23 ;; Various preferences
25 org-edit-timestamp-down-means-later t
26 org-hide-emphasis-markers t
27 org-catch-invisible-edits
'show
28 org-export-coding-system
'utf-8
29 org-fast-tag-selection-single-key
'expert
30 org-html-validation-link nil
31 org-export-kill-product-buffer-when-displayed t
35 ;; Lots of stuff from http://doc.norang.ca/org-mode.html
37 ;; Re-align tags when window shape changes
38 (with-eval-after-load 'org-agenda
39 (add-hook 'org-agenda-mode-hook
40 (lambda () (add-hook 'window-configuration-change-hook
'org-agenda-align-tags nil t
))))
43 (setq org-support-shift-select t
)
48 (setq org-refile-use-cache nil
)
50 ;; Targets include this file and any file contributing to the agenda - up to 5 levels deep
51 (setq org-refile-targets
'((nil :maxlevel .
5) (org-agenda-files :maxlevel .
5)))
53 (with-eval-after-load 'org-agenda
54 (add-to-list 'org-agenda-after-show-hook
'org-show-entry
))
56 (advice-add 'org-refile
:after
(lambda (&rest _
) (org-save-all-org-buffers)))
58 ;; Exclude DONE state tasks from refile targets
59 (defun sanityinc/verify-refile-target
()
60 "Exclude todo keywords with a done state from refile targets."
61 (not (member (nth 2 (org-heading-components)) org-done-keywords
)))
62 (setq org-refile-target-verify-function
'sanityinc
/verify-refile-target
)
64 (defun sanityinc/org-refile-anywhere
(&optional goto default-buffer rfloc msg
)
65 "A version of `org-refile' which allows refiling to any subtree."
67 (let ((org-refile-target-verify-function))
68 (org-refile goto default-buffer rfloc msg
)))
70 (defun sanityinc/org-agenda-refile-anywhere
(&optional goto rfloc no-update
)
71 "A version of `org-agenda-refile' which allows refiling to any subtree."
73 (let ((org-refile-target-verify-function))
74 (org-agenda-refile goto rfloc no-update
)))
76 ;; Targets start with the file name - allows creating level 1 tasks
77 ;;(setq org-refile-use-outline-path (quote file))
78 (setq org-refile-use-outline-path t
)
79 (setq org-outline-path-complete-in-steps nil
)
81 ;; Allow refile to create parent tasks with confirmation
82 (setq org-refile-allow-creating-parent-nodes
'confirm
)
87 (setq org-todo-keywords
88 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!/!)")
89 (sequence "PROJECT(p)" "|" "DONE(d!/!)" "CANCELLED(c@/!)")
90 (sequence "WAITING(w@/!)" "DELEGATED(e!)" "HOLD(h)" "|" "CANCELLED(c@/!)")))
91 org-todo-repeat-to-state
"NEXT")
93 (setq org-todo-keyword-faces
94 (quote (("NEXT" :inherit warning
)
95 ("PROJECT" :inherit font-lock-string-face
))))
101 (setq-default org-agenda-clockreport-parameter-plist
'(:link t
:maxlevel
3))
104 (let ((active-project-match "-INBOX/PROJECT"))
106 (setq org-stuck-projects
107 `(,active-project-match
("NEXT")))
109 (setq org-agenda-compact-blocks t
111 org-agenda-start-on-weekday nil
113 org-agenda-include-diary nil
114 org-agenda-sorting-strategy
115 '((agenda habit-down time-up user-defined-up effort-up category-keep
)
116 (todo category-up effort-up
)
117 (tags category-up effort-up
)
118 (search category-up
))
119 org-agenda-window-setup
'current-window
120 org-agenda-custom-commands
121 `(("N" "Notes" tags
"NOTE"
122 ((org-agenda-overriding-header "Notes")
123 (org-tags-match-list-sublevels t
)))
127 ((org-agenda-overriding-header "Inbox")
128 (org-tags-match-list-sublevels nil
)))
130 ((org-agenda-overriding-header "Stuck Projects")
131 (org-agenda-tags-todo-honor-ignore-options t
)
132 (org-tags-match-list-sublevels t
)
133 (org-agenda-todo-ignore-scheduled 'future
)))
135 ((org-agenda-overriding-header "Next Actions")
136 (org-agenda-tags-todo-honor-ignore-options t
)
137 (org-agenda-todo-ignore-scheduled 'future
)
138 (org-agenda-skip-function
140 (or (org-agenda-skip-subtree-if 'todo
'("HOLD" "WAITING"))
141 (org-agenda-skip-entry-if 'nottodo
'("NEXT")))))
142 (org-tags-match-list-sublevels t
)
143 (org-agenda-sorting-strategy
144 '(todo-state-down effort-up category-keep
))))
145 (tags-todo ,active-project-match
146 ((org-agenda-overriding-header "Projects")
147 (org-tags-match-list-sublevels t
)
148 (org-agenda-sorting-strategy
150 (tags-todo "-INBOX/-NEXT"
151 ((org-agenda-overriding-header "Orphaned Tasks")
152 (org-agenda-tags-todo-honor-ignore-options t
)
153 (org-agenda-todo-ignore-scheduled 'future
)
154 (org-agenda-skip-function
156 (or (org-agenda-skip-subtree-if 'todo
'("PROJECT" "HOLD" "WAITING" "DELEGATED"))
157 (org-agenda-skip-subtree-if 'nottododo
'("TODO")))))
158 (org-tags-match-list-sublevels t
)
159 (org-agenda-sorting-strategy
161 (tags-todo "/WAITING"
162 ((org-agenda-overriding-header "Waiting")
163 (org-agenda-tags-todo-honor-ignore-options t
)
164 (org-agenda-todo-ignore-scheduled 'future
)
165 (org-agenda-sorting-strategy
167 (tags-todo "/DELEGATED"
168 ((org-agenda-overriding-header "Delegated")
169 (org-agenda-tags-todo-honor-ignore-options t
)
170 (org-agenda-todo-ignore-scheduled 'future
)
171 (org-agenda-sorting-strategy
174 ((org-agenda-overriding-header "On Hold")
175 (org-agenda-skip-function
177 (or (org-agenda-skip-subtree-if 'todo
'("WAITING"))
178 (org-agenda-skip-entry-if 'nottodo
'("HOLD")))))
179 (org-tags-match-list-sublevels nil
)
180 (org-agenda-sorting-strategy
182 ;; (tags-todo "-NEXT"
183 ;; ((org-agenda-overriding-header "All other TODOs")
184 ;; (org-match-list-sublevels t)))
188 (add-hook 'org-agenda-mode-hook
'hl-line-mode
)
193 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
194 (with-eval-after-load 'org
195 (org-clock-persistence-insinuate))
196 (setq org-clock-persist t
)
197 (setq org-clock-in-resume t
)
199 ;; Save clock data and notes in the LOGBOOK drawer
200 (setq org-clock-into-drawer t
)
201 ;; Save state changes in the LOGBOOK drawer
202 (setq org-log-into-drawer t
)
203 ;; Removes clocked tasks with 0:00 duration
204 (setq org-clock-out-remove-zero-time-clocks t
)
206 ;; Show clock sums as hours and minutes, not "n days" etc.
207 (setq org-time-clocksum-format
208 '(:hours
"%d" :require-hours t
:minutes
":%02d" :require-minutes t
))
212 ;;; Show the clocked-in task - if any - in the header line
213 (defun sanityinc/show-org-clock-in-header-line
()
214 (setq-default header-line-format
'((" " org-mode-line-string
" "))))
216 (defun sanityinc/hide-org-clock-from-header-line
()
217 (setq-default header-line-format nil
))
219 (add-hook 'org-clock-in-hook
'sanityinc
/show-org-clock-in-header-line
)
220 (add-hook 'org-clock-out-hook
'sanityinc
/hide-org-clock-from-header-line
)
221 (add-hook 'org-clock-cancel-hook
'sanityinc
/hide-org-clock-from-header-line
)
223 (with-eval-after-load 'org-clock
224 (define-key org-clock-mode-line-map
[header-line mouse-2
] 'org-clock-goto
)
225 (define-key org-clock-mode-line-map
[header-line mouse-1
] 'org-clock-menu
))
231 (setq org-archive-mark-done nil
)
232 (setq org-archive-location
"%s_archive::* Archive")
236 (with-eval-after-load 'org
237 (org-babel-do-load-languages
238 'org-babel-load-languages
241 (locate-library (concat "ob-" (symbol-name (car pair
)))))
263 ;;; init-org.el ends here