Complete agenda functions
This commit is contained in:
parent
d032b286a2
commit
a698de18df
1 changed files with 288 additions and 3 deletions
|
@ -63,7 +63,7 @@
|
|||
("m" "meeting" entry (file "~/code/personal/org/capture.org")
|
||||
"* PROJ Meeting with %? :MEETING:\n%U" :clock-in t :clock-resume t))))
|
||||
(setq org-refile-targets (quote ((nil :maxlevel . 9)
|
||||
(org-agenda-files :maxlevel . 9))))
|
||||
(org-agenda-files :maxlevel . 9))))
|
||||
(add-to-list
|
||||
'ivy-completing-read-handlers-alist
|
||||
'(org-capture-refile . completing-read-default))
|
||||
|
@ -75,7 +75,80 @@
|
|||
(setq org-clock-out-when-done t)
|
||||
(setq org-clock-persist t)
|
||||
(setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
|
||||
(setq org-clock-report-include-clocking-task t))
|
||||
(setq org-clock-report-include-clocking-task t)
|
||||
(setq org-agenda-dim-blocked-tasks nil)
|
||||
(setq org-agenda-compact-blocks t)
|
||||
(setq org-agenda-custom-commands
|
||||
(quote (("N" "Notes" tags "NOTE"
|
||||
((org-agenda-overriding-header "Notes")
|
||||
(org-tags-match-list-sublevels t)))
|
||||
(" " "Agenda"
|
||||
((agenda "" nil)
|
||||
(tags "REFILE"
|
||||
((org-agenda-overriding-header "Tasks to Refile")
|
||||
(org-tags-match-list-sublevels nil)))
|
||||
(tags-todo "-CANCELLED/!"
|
||||
((org-agenda-overriding-header "Stuck Projects")
|
||||
(org-agenda-skip-function 'cf/skip-non-stuck-projects)
|
||||
(org-agenda-sorting-strategy
|
||||
'(category-keep))))
|
||||
(tags-todo "-HOLD-CANCELLED/!"
|
||||
((org-agenda-overriding-header "Projects")
|
||||
(org-agenda-skip-function 'cf/skip-non-projects)
|
||||
(org-tags-match-list-sublevels 'indented)
|
||||
(org-agenda-sorting-strategy
|
||||
'(category-keep))))
|
||||
(tags-todo "-CANCELLED/!NEXT"
|
||||
((org-agenda-overriding-header (concat "Project Next Tasks"
|
||||
(if cf/hide-scheduled-and-waiting-next-tasks
|
||||
""
|
||||
" (including WAITING and SCHEDULED tasks)")))
|
||||
(org-agenda-skip-function 'cf/skip-projects-and-habits-and-single-tasks)
|
||||
(org-tags-match-list-sublevels t)
|
||||
(org-agenda-todo-ignore-scheduled cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-todo-ignore-deadlines cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-todo-ignore-with-date cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-sorting-strategy
|
||||
'(todo-state-down effort-up category-keep))))
|
||||
(tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
|
||||
((org-agenda-overriding-header (concat "Project Subtasks"
|
||||
(if cf/hide-scheduled-and-waiting-next-tasks
|
||||
""
|
||||
" (including WAITING and SCHEDULED tasks)")))
|
||||
(org-agenda-skip-function 'cf/skip-non-project-tasks)
|
||||
(org-agenda-todo-ignore-scheduled cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-todo-ignore-deadlines cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-todo-ignore-with-date cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-sorting-strategy
|
||||
'(category-keep))))
|
||||
(tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
|
||||
((org-agenda-overriding-header (concat "Standalone Tasks"
|
||||
(if cf/hide-scheduled-and-waiting-next-tasks
|
||||
""
|
||||
" (including WAITING and SCHEDULED tasks)")))
|
||||
(org-agenda-skip-function 'cf/skip-project-tasks)
|
||||
(org-agenda-todo-ignore-scheduled cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-todo-ignore-deadlines cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-todo-ignore-with-date cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-sorting-strategy
|
||||
'(category-keep))))
|
||||
(tags-todo "-CANCELLED+WAITING|HOLD/!"
|
||||
((org-agenda-overriding-header (concat "Waiting and Postponed Tasks"
|
||||
(if cf/hide-scheduled-and-waiting-next-tasks
|
||||
""
|
||||
" (including WAITING and SCHEDULED tasks)")))
|
||||
(org-agenda-skip-function 'cf/skip-non-tasks)
|
||||
(org-tags-match-list-sublevels nil)
|
||||
(org-agenda-todo-ignore-scheduled cf/hide-scheduled-and-waiting-next-tasks)
|
||||
(org-agenda-todo-ignore-deadlines cf/hide-scheduled-and-waiting-next-tasks)))
|
||||
(tags "-REFILE/"
|
||||
((org-agenda-overriding-header "Tasks to Archive")
|
||||
(org-agenda-skip-function 'cf/skip-non-archivable-tasks)
|
||||
(org-tags-match-list-sublevels nil))))
|
||||
nil)))))
|
||||
|
||||
|
||||
(map! :map global-map :leader "a" 'org-agenda)
|
||||
|
||||
(defun cf/clock-in-to-next (kw)
|
||||
(when (not (and (boundp 'org-capture-mode) org-capture-mode))
|
||||
|
@ -87,6 +160,16 @@
|
|||
(cf/is-project-p))
|
||||
"TODO"))))
|
||||
|
||||
(defun cf/find-project-task ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((parent-task (save-excursion (org-back-to-heading 'invisible-ok) (point))))
|
||||
(while (org-up-heading-safe)
|
||||
(when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
|
||||
(setq parent-task (point))))
|
||||
(goto-char parent-task)
|
||||
parent-task)))
|
||||
|
||||
(defun cf/is-project-p ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
|
@ -102,7 +185,7 @@
|
|||
(setq has-subtask t))))
|
||||
(and is-a-task has-subtask))))
|
||||
|
||||
(defun bh/is-task-p ()
|
||||
(defun cf/is-task-p ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((has-subtask)
|
||||
|
@ -117,6 +200,208 @@
|
|||
(setq has-subtask t))))
|
||||
(and is-a-task (not has-subtask)))))
|
||||
|
||||
(defun cf/is-project-subtree-p ()
|
||||
(let ((task (save-excursion (org-back-to-heading 'invisible-ok)
|
||||
(point))))
|
||||
(save-excursion
|
||||
(cf/find-project-task)
|
||||
(if (equal (point) task)
|
||||
nil
|
||||
t))))
|
||||
|
||||
(defun cf/is-subproject-p ()
|
||||
(let ((is-subproject)
|
||||
(is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
|
||||
(save-excursion
|
||||
(while (and (not is-subproject) (org-up-heading-safe))
|
||||
(when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
|
||||
(setq is-subproject t))))
|
||||
(and is-a-task is-subproject)))
|
||||
|
||||
(defun cf/list-sublevels-for-projects-indented ()
|
||||
(if (marker-buffer org-agenda-restrict-begin)
|
||||
(setq org-tags-match-list-sublevels 'indented)
|
||||
(setq org-tags-match-list-sublevels nil))
|
||||
nil)
|
||||
|
||||
(defun cf/list-sublevels-for-projects ()
|
||||
(if (marker-buffer org-agenda-restrict-begin)
|
||||
(setq org-tags-match-list-sublevels t)
|
||||
(setq org-tags-match-list-sublevels nil))
|
||||
nil)
|
||||
|
||||
(defvar cf/hide-scheduled-and-waiting-next-tasks t)
|
||||
|
||||
|
||||
(defun cf/toggle-next-task-display ()
|
||||
(interactive)
|
||||
(setq cf/hide-scheduled-and-waiting-next-tasks (not cf/hide-scheduled-and-waiting-next-tasks))
|
||||
(when (equal major-mode 'org-agenda-mode)
|
||||
(org-agenda-redo))
|
||||
(message "%s WAITING and SCHEDULED NEXT Tasks" (if cf/hide-scheduled-and-waiting-next-tasks "Hide" "Show")))
|
||||
|
||||
|
||||
(defun cf/skip-stuck-projects ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
|
||||
(if (cf/is-project-p)
|
||||
(let* ((subtree-end (save-excursion (org-end-of-subtree t)))
|
||||
(has-next ))
|
||||
(save-excursion
|
||||
(forward-line 1)
|
||||
(while (and (not has-next) (< (point) subtree-end) (re-search-forward "^\\*+ NEXT " subtree-end t))
|
||||
(unless (member "WAITING" (org-get-tags-at))
|
||||
(setq has-next t))))
|
||||
(if has-next
|
||||
nil
|
||||
next-headline)) ; a stuck project, has subtasks but no next task
|
||||
nil))))
|
||||
|
||||
(defun cf/skip-non-stuck-projects ()
|
||||
;; (cf/list-sublevels-for-projects-indented)
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
|
||||
(if (cf/is-project-p)
|
||||
(let* ((subtree-end (save-excursion (org-end-of-subtree t)))
|
||||
(has-next ))
|
||||
(save-excursion
|
||||
(forward-line 1)
|
||||
(while (and (not has-next) (< (point) subtree-end) (re-search-forward "^\\*+ NEXT " subtree-end t))
|
||||
(unless (member "WAITING" (org-get-tags-at))
|
||||
(setq has-next t))))
|
||||
(if has-next
|
||||
next-headline
|
||||
nil)) ; a stuck project, has subtasks but no next task
|
||||
next-headline))))
|
||||
|
||||
(defun cf/skip-non-projects ()
|
||||
;; (cf/list-sublevels-for-projects-indented)
|
||||
(if (save-excursion (cf/skip-non-stuck-projects))
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((subtree-end (save-excursion (org-end-of-subtree t))))
|
||||
(cond
|
||||
((cf/is-project-p)
|
||||
nil)
|
||||
((and (cf/is-project-subtree-p) (not (cf/is-task-p)))
|
||||
nil)
|
||||
(t
|
||||
subtree-end))))
|
||||
(save-excursion (org-end-of-subtree t))))
|
||||
|
||||
(defun cf/skip-non-tasks ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
|
||||
(cond
|
||||
((cf/is-task-p)
|
||||
nil)
|
||||
(t
|
||||
next-headline)))))
|
||||
|
||||
(defun cf/skip-project-trees-and-habits ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((subtree-end (save-excursion (org-end-of-subtree t))))
|
||||
(cond
|
||||
((cf/is-project-p)
|
||||
subtree-end)
|
||||
((org-is-habit-p)
|
||||
subtree-end)
|
||||
(t
|
||||
nil)))))
|
||||
|
||||
(defun cf/skip-projects-and-habits-and-single-tasks ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
|
||||
(cond
|
||||
((org-is-habit-p)
|
||||
next-headline)
|
||||
((and cf/hide-scheduled-and-waiting-next-tasks
|
||||
(member "WAITING" (org-get-tags-at)))
|
||||
next-headline)
|
||||
((cf/is-project-p)
|
||||
next-headline)
|
||||
((and (cf/is-task-p) (not (cf/is-project-subtree-p)))
|
||||
next-headline)
|
||||
(t
|
||||
nil)))))
|
||||
|
||||
(defun cf/skip-project-tasks-maybe ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let* ((subtree-end (save-excursion (org-end-of-subtree t)))
|
||||
(next-headline (save-excursion (or (outline-next-heading) (point-max))))
|
||||
(limit-to-project (marker-buffer org-agenda-restrict-begin)))
|
||||
(cond
|
||||
((cf/is-project-p)
|
||||
next-headline)
|
||||
((org-is-habit-p)
|
||||
subtree-end)
|
||||
((and (not limit-to-project)
|
||||
(cf/is-project-subtree-p))
|
||||
subtree-end)
|
||||
((and limit-to-project
|
||||
(cf/is-project-subtree-p)
|
||||
(member (org-get-todo-state) (list "NEXT")))
|
||||
subtree-end)
|
||||
(t
|
||||
nil)))))
|
||||
|
||||
(defun cf/skip-project-tasks ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let* ((subtree-end (save-excursion (org-end-of-subtree t))))
|
||||
(cond
|
||||
((cf/is-project-p)
|
||||
subtree-end)
|
||||
((org-is-habit-p)
|
||||
subtree-end)
|
||||
((cf/is-project-subtree-p)
|
||||
subtree-end)
|
||||
(t
|
||||
nil)))))
|
||||
|
||||
|
||||
(defun cf/skip-non-project-tasks ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let* ((subtree-end (save-excursion (org-end-of-subtree t)))
|
||||
(next-headline (save-excursion (or (outline-next-heading) (point-max)))))
|
||||
(cond
|
||||
((cf/is-project-p)
|
||||
next-headline)
|
||||
((org-is-habit-p)
|
||||
subtree-end)
|
||||
((and (cf/is-project-subtree-p)
|
||||
(member (org-get-todo-state) (list "NEXT")))
|
||||
subtree-end)
|
||||
((not (cf/is-project-subtree-p))
|
||||
subtree-end)
|
||||
(t
|
||||
nil)))))
|
||||
|
||||
|
||||
(defun cf/skip-projects-and-habits ()
|
||||
(save-restriction
|
||||
(widen)
|
||||
(let ((subtree-end (save-excursion (org-end-of-subtree t))))
|
||||
(cond
|
||||
((cf/is-project-p)
|
||||
subtree-end)
|
||||
((org-is-habit-p)
|
||||
subtree-end)
|
||||
(t
|
||||
nil)))))
|
||||
|
||||
(defun cf/skip-non-subprojects ()
|
||||
(let ((next-headline (save-excursion (outline-next-heading))))
|
||||
(if (cf/is-subproject-p)
|
||||
nil
|
||||
next-headline)))
|
||||
|
||||
;; Enable editorconfig
|
||||
(editorconfig-mode 1)
|
||||
|
|
Loading…
Add table
Reference in a new issue