legacy-dotfiles/emacs/site-lisp/org-init.el

169 lines
6.7 KiB
EmacsLisp
Raw Normal View History

2012-10-22 23:58:46 +02:00
;;; org-init.el --- Org initialization
2013-04-10 22:05:48 +02:00
;; Copyright (C) 2012 Tom Willemse
2012-10-22 23:58:46 +02:00
2013-04-10 22:05:48 +02:00
;; Author: Tom Willemse <slash@drd>
2012-10-22 23:58:46 +02:00
;; Keywords:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(require 'appt)
(require 'oni)
(require 'org-contacts)
(require 'org-habit)
(require 'org-protocol)
(autoload 'org-clocking-p "org-clock")
2012-10-22 23:58:46 +02:00
(eval-after-load "org-crypt"
'(org-crypt-use-before-save-magic))
(defun oni:note-template ()
(concat
"* %<%c>\n"
" :DIRECTORY: =" default-directory "=\n"
(when (buffer-file-name) " :FILE: [[file:%F][%F]]\n")
(when (org-clocking-p) " :TASK: %K\n")
"\n %?"))
2013-01-15 12:11:41 +01:00
(defun oni:org-maybe-outline-path ()
(let ((outline-path (org-format-outline-path (org-get-outline-path))))
(unless (string= outline-path "")
(setq outline-path (concat "[ " outline-path " ] ")))
outline-path))
(defun oni:set-org-agenda-files ()
"Set `org-agenda-files` according to the current time."
(interactive)
(let* ((current-time (decode-time))
(current-hour (nth 2 current-time))
(current-dow (nth 6 current-time)))
(if (or (= current-dow 6) (= current-dow 0) ; Saturday or Sunday
(< current-hour 9) (>= current-hour 17))
(setq org-agenda-files
(append oni:personal-agenda-files oni:common-agenda-files))
(setq org-agenda-files
(append oni:work-agenda-files oni:common-agenda-files)))))
(defvar oni:personal-agenda-files
(list (expand-file-name "~/documents/org/tasks"))
"My personal agenda, should only show up at times I don't have
to work.")
(defvar oni:work-agenda-files
2013-02-07 10:03:52 +01:00
(list (expand-file-name "~/documents/org/work"))
2013-01-15 12:11:41 +01:00
"My work agenda, should only show up at times I work.")
(defvar oni:common-agenda-files
(list (expand-file-name "~/documents/org/dailies")
(expand-file-name "~/documents/org/misc/contacts.org")
(expand-file-name "~/documents/org/misc/bookmarks.org"))
"Agenda files that are work-agnostic, should always show up.")
2013-03-10 13:36:55 +01:00
(setq org-agenda-cmp-user-defined (lambda (a b) 1))
2012-10-22 23:58:46 +02:00
(setq org-agenda-custom-commands
2013-01-15 12:11:41 +01:00
'(("P" . "Personal only")
("Pa" "Personal agenda" agenda ""
((org-agenda-files (append oni:personal-agenda-files
oni:common-agenda-files))))
("Pt" "Personal todo" todo ""
2013-01-15 12:11:41 +01:00
((org-agenda-files (append oni:personal-agenda-files
oni:common-agenda-files))))
("W" . "Work only")
("Wa" "Work agenda" agenda ""
((org-agenda-files (append oni:work-agenda-files
oni:common-agenda-files))))
("Wt" "Work todo" todo ""
((org-agenda-files (append oni:work-agenda-files
oni:common-agenda-files))))))
2012-11-27 11:13:24 +01:00
(setq org-agenda-prefix-format
'((agenda . " %i %-12:c%?-12t% s")
(timeline . " % s")
2013-01-15 12:11:41 +01:00
(todo . " %i %-12:c %(oni:org-maybe-outline-path)")
(tags . " %i %-12:c %(oni:org-maybe-outline-path)")
2012-11-27 11:13:24 +01:00
(search . " %i %-12:c")))
2012-10-22 23:58:46 +02:00
(setq org-agenda-sorting-strategy
'((agenda habit-down time-up priority-down category-keep)
2013-05-15 17:35:51 +02:00
(todo priority-down user-defined-down)
2012-10-22 23:58:46 +02:00
(tags priority-down category-keep)
(search category-keep)))
2013-05-15 17:35:51 +02:00
(setq org-agenda-tags-column (1+ (- (window-width))))
(setq org-directory (expand-file-name "~/documents/org"))
(setq org-default-notes-file (concat org-directory "/org"))
2012-10-22 23:58:46 +02:00
(setq org-capture-templates
`(("t" "Task" entry (file "~/documents/org/tasks")
2012-10-22 23:58:46 +02:00
"* TODO %?")
2012-12-04 17:45:43 +01:00
("T" "Linked task" entry (file "~/documents/org/tasks")
"* TODO %?\n\n %a")
2013-05-15 17:35:51 +02:00
("a" "Appointment" entry (file "~/documents/org/tasks")
"* %?\n SCHEDULED: %^T\n\n %a")
("n" "General note" entry (file ,org-default-notes-file)
(function oni:note-template))))
2012-10-22 23:58:46 +02:00
(setq org-contacts-files '("~/documents/org/misc/contacts.org"))
2012-11-27 11:13:24 +01:00
(setq org-agenda-show-outline-path nil)
2012-10-22 23:58:46 +02:00
(setq org-agenda-todo-ignore-deadlines 'far)
(setq org-agenda-todo-ignore-scheduled t)
(setq org-export-htmlize-output-type 'css)
(setq org-feed-alist
'(("MyEpisodes"
"http://www.myepisodes.com/rss.php?feed=mylist&uid=Slash&pwdmd5=04028968e1f0b7ee678b748a4320ac17"
"~/documents/org/tasks" "MyEpisodes"
:formatter oni:myepisodes-formatter)))
(setq org-fontify-done-headline t)
2012-10-22 23:58:46 +02:00
(setq org-hide-emphasis-markers t)
(setq org-outline-path-complete-in-steps t)
(setq org-refile-allow-creating-parent-nodes t)
(setq org-refile-targets '((nil . (:maxlevel . 6))))
(setq org-refile-use-outline-path 'file)
(setq org-return-follows-link t)
(setq org-src-fontify-natively t)
2013-05-15 17:35:51 +02:00
(setq org-tags-column (- 70))
2012-10-22 23:58:46 +02:00
(setq org-tags-exclude-from-inheritance '("crypt"))
(setq org-todo-keyword-faces
'(("TODO" :foreground "#ff756e" :background "#171719" :box (:width 1 :color "#282830"))
("DONE" :foreground "#9ad870" :background "#222224" :box (:width 1 :color "#333335"))
("SUCCEEDED" :foreground "#9ad870" :background "#222224" :box (:width 1 :color "#333335"))
("WAITING" :foreground "#ffbb56" :background "#171719" :box (:width 1 :color "#282830"))
("CANCELLED" :foreground "#93d8d8" :background "#222224" :box (:width 1 :color "#333335"))
("FAILED" :foreground "#93d8d8" :background "#222224" :box (:width 1 :color "#333335"))
("WIP" :foreground "#ff756e" :background "#171719" :box (:width 1 :color "#282830"))
("HOLD" :foreground "#ffbb56" :background "#171719" :box (:width 1 :color "#282830"))
("ACQUIRE" :foreground "#ff756e" :background "#171719" :box (:width 1 :color "#282830"))
("IGNORED" :foreground "#999999" :background "#222224" :box (:width 1 :color "#333335"))))
2012-10-22 23:58:46 +02:00
(setq org-use-fast-todo-selection t)
2013-05-15 17:35:51 +02:00
(setq org-agenda-skip-function-global 'oni:skip-ex-tag)
2012-11-05 21:05:16 +01:00
(setq org-use-property-inheritance '("slug"))
2012-10-22 23:58:46 +02:00
2012-12-06 22:40:43 +01:00
(add-hook 'org-agenda-mode-hook 'org-agenda-to-appt)
2012-10-22 23:58:46 +02:00
(add-to-list 'org-modules 'habit)
(org-indent-mode t)
(org-agenda-to-appt)
(ad-activate 'org-agenda-redo)
2013-01-15 12:11:41 +01:00
(oni:set-org-agenda-files)
(run-at-time "09:01" (* 60 60 24) 'oni:set-org-agenda-files)
(run-at-time "17:01" (* 60 60 24) 'oni:set-org-agenda-files)
2013-01-15 12:11:41 +01:00
2012-10-22 23:58:46 +02:00
(provide 'org-init)
;;; org-init.el ends here