(gx/maybe-require-package 'org-ql) (defvar gx/org-agenda-block--today-schedule '(agenda "" ((org-agenda-span 1) (org-agenda-overriding-header "Today's Schedule"))) "A block showing today's schedule.") (defvar gx/org-agenda-block--weekly-schedule '(agenda "" ((org-agenda-overriding-header "Weekly Schedule") (org-agenda-ndays-to-span 7))) "A block showing weekly schedule.") (defvar gx/org-agenda-block--stuck-projects '(org-ql-block '(and (or (tags "PROJECT") (not (ancestors (todo)))) (todo) (not (done)) (not (todo "SOMEDAY")) (not (todo "NEXT")) (not (scheduled)) (not (descendants (todo "NEXT"))) (not (descendants (scheduled)))) ((org-ql-block-header "Stuck Projects"))) "A block showing stuck projects.") (defvar gx/org-agenda-block--unwilling-to-do '(tags-todo "UNWILLING" ((org-agenda-overriding-header "Unwilling to do"))) "A block showing tasks I am not willing to do ...") (defvar gx/org-agenda-block--week-at-a-glance '(agenda "" ((org-agenda-span 7) (org-agenda-repeating-timestamp-show-all t) (org-agenda-entry-types '(:deadline :scheduled)) (org-agenda-overriding-header "Week at a Glance"))) "A block showing the tasks scheduled or due this week.") (defvar gx/org-agenda-block--attention '(org-ql-block '(and (not (todo "WAITING")) (or (tags "URGENT" "FLAGGED") (priority "A"))) ((org-ql-block-header "ATTENTION"))) "A block showing tasks require attention.") (defvar gx/org-agenda-block--waiting-not-scheduled '(org-ql-block '(and (todo "WAITING") (not (scheduled))) ((org-ql-block-header "Waiting unscheduled tasks"))) "A block showing waiting and not scheduled tasks.") (defvar gx/org-agenda-block--next-not-scheduled '(org-ql-block '(and (todo "NEXT") (not (scheduled))) ((org-ql-block-header "Next unscheduled tasks"))) "A block showing next unscheduled tasks.") (defun gx/org-agenda-quit (fn) (org-save-all-org-buffers) (funcall fn)) (advice-add 'org-agenda-quit :around 'gx/org-agenda-quit) (defun gx/org-refile (fn &optional arg default-buffer rfloc msg) (funcall-interactively fn arg default-buffer rfloc msg) (org-save-all-org-buffers)) (advice-add 'org-refile :around 'gx/org-refile) (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) (add-hook 'org-capture-after-finalize-hook 'org-save-all-org-buffers) ;; keybinds (with-eval-after-load 'evil (evil-define-key 'normal 'global (kbd "a") 'org-agenda (kbd "l") 'org-store-link (kbd "co") 'org-capture (kbd "fn") 'org-roam-node-find (kbd "cn") 'org-roam-dailies-goto-today) (evil-define-key 'normal org-mode-map (kbd "TAB") 'org-cycle (kbd "RET") 'org-open-at-point (kbd "H") 'org-toggle-heading (kbd "r") 'org-refile ;; set (kbd "ss") 'org-schedule (kbd "sd") 'org-deadline (kbd "sp") 'org-set-property (kbd "st") 'org-set-tags-command ;; insert (kbd "il") 'org-insert-link (kbd "ih") 'org-insert-heading (kbd "in") 'org-roam-node-insert ;; clock (kbd "ci") 'org-clock-in (kbd "co") 'org-clock-out (kbd "cr") 'org-clock-report (kbd "cc") 'org-clock-cancel ;; priority (kbd "+") 'org-priority-up (kbd "-") 'org-priority-down) (evil-set-initial-state 'org-agenda-mode 'motion) (evil-define-key 'motion org-agenda-mode-map ;; motion (kbd "j") 'org-agenda-next-line (kbd "k") 'org-agenda-previous-line (kbd "gg") 'evil-goto-first-line (kbd "G") 'evil-goto-line (kbd "C-n") 'org-agenda-next-item (kbd "C-p") 'org-agenda-previous-item (kbd "[[") 'org-agenda-earlier (kbd "]]") 'org-agenda-later ;; actions (kbd "RET") 'org-agenda-switch-to (kbd "TAB") 'org-agenda-goto (kbd "t") 'org-agenda-todo (kbd "r") 'org-agenda-refile (kbd "+") 'org-agenda-priority-up (kbd "-") 'org-agenda-priority-down (kbd "H") 'org-agenda-do-date-earlier (kbd "L") 'org-agenda-do-date-later (kbd "o") 'org-agenda-add-note (kbd "A") 'org-agenda-append-agenda (kbd "C") 'org-agenda-capture (kbd "R") 'org-agenda-redo (kbd "dd") 'org-agenda-kill ;; bulk (kbd "m") 'org-agenda-bulk-toggle (kbd "x") 'org-agenda-bulk-action ;; set (kbd "ss") 'org-agenda-schedule (kbd "sd") 'org-agenda-deadline (kbd "st") 'org-agenda-set-tags (kbd "sT") 'org-timer-set-timer (kbd "se") 'org-agenda-set-effort ;; filter (kbd "fc") 'org-agenda-filter-by-category (kbd "fr") 'org-agenda-filter-by-regexp (kbd "fe") 'org-agenda-filter-by-effort (kbd "ft") 'org-agenda-filter-by-tag (kbd "F") 'org-agenda-filter-remove-all ;; clock (kbd "ci") 'org-agenda-clock-in (kbd "co") 'org-agenda-clock-out (kbd "cc") 'org-agenda-clock-cancel (kbd "cg") 'org-agenda-clock-goto (kbd "cr") 'org-agenda-clockreport-mode ;; goto (kbd "gc") 'org-agenda-goto-calendar (kbd "u") 'org-agenda-undo)) (add-hook 'org-mode-hook (lambda () (setq truncate-lines nil) (setq tab-width 4))) (setq org-default-notes-file "~/words/journals/inbox.org") (setq org-agenda-start-on-weekday 0) ;; appearance (setq org-src-tab-acts-natively t) (setq org-adapt-indentation nil) (setq org-startup-indented t) (setq org-descriptive-links t) (setq org-tags-column (- fill-column)) (setq org-agenda-tags-column org-tags-column) (setq org-startup-folded 'showall) (with-eval-after-load 'org-indent (gx/diminish 'org-indent-mode)) ;; todo (setq org-todo-keywords '((sequence "TODO(t)" ; to do later "NEXT(n)" ; doing now or to do soon "WAITING(w)" "SOMEDAY(s)" "|" "DONE(d)" "CANCELLED(c)"))) (setq org-log-done t) (setq org-log-into-drawer t) ;; tags (setq org-tags-exclude-from-inheritance '("PROJECT" "UNWILLING")) (setq org-tag-alist '((:startgroup . nil) ("@work" . ?w) ("@home" . ?h) ("errants" . ?e) (:endgroup . nil) ("phone" . ?m) ("FLAGGED" . ?f) ("URGENT" . ?u) ("UNWILLING" . ?x) ("PROJECT" . ?p))) ;; refile (setq org-refile-targets '((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9)) org-outline-path-complete-in-steps nil org-refile-use-outline-path 'file) ;; capture (setq org-capture-templates '(("t" "TODO" entry (file+headline org-default-notes-file "Tasks") "* TODO %?\nCaptured on %U\n %i\n %a") ("j" "Journal" entry (file+datetree org-default-notes-file) "* %?\nCaptured on %U\n %i\n %a"))) ;; clock (setq org-clock-persist 'history) (with-eval-after-load 'org (org-clock-persistence-insinuate)) ;; modules (with-eval-after-load 'org (add-to-list 'org-modules 'org-habit t) (add-to-list 'org-modules 'org-tempo t)) (setq org-confirm-babel-evaluate nil) ;; babel (with-eval-after-load 'org (org-babel-do-load-languages 'org-babel-load-languages '((shell . t) (plantuml . t)))) ;; agenda (setq org-agenda-dim-blocked-tasks nil) (setq org-agenda-skip-deadline-prewarning-if-scheduled t) (setq org-deadline-warning-days 30) (setq org-agenda-window-setup 'current-window) ;; (setq org-agenda-prefix-format ;; '((agenda . "%i %-12:c%?-12t% s %b") ;; (timeline . " % s") ;; (todo . "%i %-12:c %b") ;; (tags . "%i %-12:c") ;; (search . " %i %-12:c"))) (setq org-agenda-custom-commands `((" " "Daily agenda and all important TODOs" (,gx/org-agenda-block--today-schedule ,gx/org-agenda-block--attention ,gx/org-agenda-block--unwilling-to-do ;; (tags-todo "computer|@office|phone") ;; (tags "PROJECT+CATEGORY=\"elephants\"") ,gx/org-agenda-block--stuck-projects ,gx/org-agenda-block--next-not-scheduled ,gx/org-agenda-block--waiting-not-scheduled ,gx/org-agenda-block--week-at-a-glance)) ("d" "Upcoming deadlines" agenda "" ((org-agenda-time-grid nil) (org-deadline-warning-days 365) (org-agenda-entry-types '(:deadline)))) ("g" . "GTD contexts") ("gh" "Home" tags-todo "home") ("p" . "Priorities") ("pa" "A items" tags-todo "+PRIORITIES=\"A\"") ("pb" "B items" tags-todo "+PRIORITIES=\"B\"") ("pc" "C items" tags-todo "+PRIORITIES=\"C\""))) ;; evil (when (gx/maybe-require-package 'evil-org) (add-hook 'org-mode-hook 'evil-org-mode) (add-hook 'org-agenda-mode-hook 'evil-org-mode)) (autoload 'evil-org-agenda-set-keys "evil-org-agenda") ;; (add-hook 'evil-org-mode-hook ;; (lambda () ;; (setq evil-want-C-i-jump nil))) (with-eval-after-load 'evil-org (evil-org-set-key-theme '(navigation insert textobjects additional calendar todo)) (gx/diminish 'evil-org-mode)) ;; roam (when (gx/maybe-require-package 'org-roam) (add-hook 'org-mode-hook 'org-roam-db-autosync-mode)) (setq org-roam-directory (file-truename "~/words")) (setq org-roam-db-gc-threshold most-positive-fixnum) (setq org-roam-dailies-directory "journals/") (setq org-roam-dailies-capture-templates '(("d" "daily" entry "* %?" :target (file+head "%<%Y/%Y-%m-%d>.org" "#+title: %<%a %d %b %Y>\n")) ("w" "weekly" entry "* %?" :target (file+head "%<%Y/week%V>.org" "#+title: Week %<%V %Y>\n")) ("m" "monthly" entry "* %?" :target (file+head "%<%Y/%Y-%m>.org" "#+title: %<%B %Y>\n")) ("y" "yearly" entry "* %?" :target (file+head "%<%Y/%Y>.org" "#+title: %<%Y>\n")))) ;; roam ui (gx/maybe-require-package 'org-roam-ui) (setq org-roam-ui-follow t org-roam-ui-sync-theme t org-roam-ui-update-on-save t org-roam-ui-open-at-start t) ;; alert (when (gx/maybe-require-package 'org-alert) (autoload 'org-alert-enable "org-alert") (when (daemonp) (org-alert-enable))) (when *is-a-linux* (setq alert-default-style 'libnotify)) (when *is-a-mac* (setq alert-default-style 'osx-notifier)) (setq org-alert-interval 60) (provide 'init-org)