Skip to content

Commit

Permalink
lots of small changes to Org and Org Agenda
Browse files Browse the repository at this point in the history
  • Loading branch information
gjstein committed Apr 19, 2020
1 parent 6330ee6 commit 615c188
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 24 deletions.
44 changes: 29 additions & 15 deletions config/gs-org-agenda.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@

(defun gs/select-projects ()
"Selects tasks which are project headers"
(gs/select-with-tag-function #'bh/is-project-p))
(gs/select-with-tag-function #'gs/is-project-p))

(defun gs/select-project-tasks ()
"Skips tags which belong to projects (and is not a project itself)"
(gs/select-with-tag-function
#'(lambda () (and
(not (bh/is-project-p))
(bh/is-project-subtree-p)))))
(not (gs/is-project-p))
(gs/is-project-subtree-p)))))

(defun gs/select-standalone-tasks ()
"Skips tags which belong to projects. Is neither a project, nor does it blong to a project"
(gs/select-with-tag-function
#'(lambda () (and
(not (bh/is-project-p))
(not (bh/is-project-subtree-p))))))
(not (gs/is-project-p))
(not (gs/is-project-subtree-p))))))

(defun gs/select-projects-and-standalone-tasks ()
"Skips tags which are not projects"
(gs/select-with-tag-function
#'(lambda () (or
(bh/is-project-p)
(bh/is-project-subtree-p)))))
(gs/is-project-p)
(gs/is-project-subtree-p)))))

(defun gs/org-agenda-project-warning ()
"Is a project stuck or waiting. If the project is not stuck,
Expand All @@ -86,7 +86,7 @@ show this warning instead."

(defun gs/org-agenda-project-is-stuck ()
"Is a project stuck"
(if (bh/is-project-p) ; first, check that it's a project
(if (gs/is-project-p) ; first, check that it's a project
(let* ((subtree-end (save-excursion (org-end-of-subtree t)))
(has-next))
(save-excursion
Expand All @@ -101,7 +101,7 @@ show this warning instead."

(defun gs/org-agenda-project-is-waiting ()
"Is a project stuck"
(if (bh/is-project-p) ; first, check that it's a project
(if (gs/is-project-p) ; first, check that it's a project
(let* ((subtree-end (save-excursion (org-end-of-subtree t))))
(save-excursion
(re-search-forward "^\\*+ WAITING" subtree-end t)))
Expand All @@ -124,7 +124,6 @@ show this warning instead."
(concat "{" loc "} ")
"")))


;;;; Agenda block definitions

(defvar gs-org-agenda-block--today-schedule
Expand Down Expand Up @@ -154,10 +153,10 @@ show this warning instead."
"A block showing my schedule for the next couple weeks.")

(defvar gs-org-agenda-block--refile
'(tags "REFILE-ARCHIVE-REFILE=\"nil\""
((org-agenda-overriding-header "Tasks to Refile:")
'(tags "REFILE-ARCHIVE-REFILE=\"nil\"|INFO"
((org-agenda-overriding-header "Headings needing refiling or other info:")
(org-tags-match-list-sublevels nil)))
"Headings with the refile tag.")
"Headings needing refiling or other info.")

(defvar gs-org-agenda-block--next-tasks
'(tags-todo "-INACTIVE-SOMEDAY-CANCELLED-ARCHIVE/!NEXT"
Expand Down Expand Up @@ -201,6 +200,11 @@ show this warning instead."
(org-tags-match-list-sublevels nil)))
"Someday projects and tasks.")

(defvar gs-org-agenda-block--motivators
'(todo "AMOTIVATOR|TMOTIVATOR|CMOTIVATOR"
((org-agenda-overriding-header "Motivators (Active/Tangible/Conceptual)")))
"All my 'motivators' across my projects.")

(defvar gs-org-agenda-block--end-of-agenda
'(tags "ENDOFAGENDA"
((org-agenda-overriding-header "End of Agenda")
Expand All @@ -219,6 +223,11 @@ show this warning instead."
(org-agenda-todo-ignore-scheduled t))
"Display settings for my agenda views.")

(defvar gs-org-agenda-entry-display-settings
'(,gs-org-agenda-display-settings
(org-agenda-entry-text-mode t))
"Display settings for my agenda views with entry text.")

;;;; Agenda Definitions

(setq org-agenda-custom-commands
Expand All @@ -245,6 +254,7 @@ show this warning instead."
,gs-org-agenda-block--remaining-project-tasks
,gs-org-agenda-block--inactive-tags
,gs-org-agenda-block--someday-tags
,gs-org-agenda-block--motivators
,gs-org-agenda-block--end-of-agenda)
,gs-org-agenda-display-settings)
("rn" "Agenda Review (next tasks)"
Expand Down Expand Up @@ -272,6 +282,10 @@ show this warning instead."
,gs-org-agenda-block--inactive-tags
,gs-org-agenda-block--end-of-agenda)
,gs-org-agenda-display-settings)
("rm" "Agenda Review (motivators)"
(,gs-org-agenda-block--motivators
,gs-org-agenda-block--end-of-agenda)
,gs-org-agenda-entry-display-settings)
))


Expand Down Expand Up @@ -319,14 +333,14 @@ show this warning instead."
(progn
(put-text-property
(+ 14 (point-at-bol)) (match-end 0)
'face 'org-time-grid)
'face 'font-lock-comment-face) ; also 'org-time-grid
))
(goto-char (point-min))
(while (re-search-forward ":TENT:" nil t)
(progn
(put-text-property
(+ 14 (point-at-bol)) (match-end 0)
'face 'org-time-grid)
'face 'font-lock-comment-face)
))
))
(add-hook 'org-agenda-finalize-hook 'gs/org-agenda-project-highlight-warning)
Expand Down
54 changes: 46 additions & 8 deletions config/gs-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

;; Display properties
(setq org-cycle-separator-lines 0)
(setq org-tags-column 80)
(setq org-tags-column 8)
(setq org-latex-prefer-user-labels t)

;; Dim blocked tasks (and other settings)
Expand Down Expand Up @@ -41,18 +41,24 @@
;; == Custom State Keywords ==
(setq org-use-fast-todo-selection t)
(setq org-todo-keywords
'((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
(sequence "WAITING(w@/!)" "INACTIVE(i)" "SOMEDAY(s)" "|" "CANCELLED(c@/!)" "MEETING")))
'((sequence "TODO(t)" "NEXT(n)" "PROJ(p)" "|" "DONE(d)")
(sequence "TASK(T)")
(sequence "AMOTIVATOR(MA)" "TMOTIVATOR(MT)" "CMOTIVATOR(MC)")
(sequence "WAITING(w@/!)" "INACTIVE(i)" "SOMEDAY(s)" "|" "CANCELLED(c@/!)")))
;; Custom colors for the keywords
(setq org-todo-keyword-faces
'(("TODO" :foreground "red" :weight bold)
("TASK" :foreground "#5C888B" :weight bold)
("NEXT" :foreground "blue" :weight bold)
("PROJ" :foreground "magenta" :weight bold)
("AMOTIVATOR" :foreground "#F06292" :weight bold)
("TMOTIVATOR" :foreground "#AB47BC" :weight bold)
("CMOTIVATOR" :foreground "#5E35B1" :weight bold)
("DONE" :foreground "forest green" :weight bold)
("WAITING" :foreground "orange" :weight bold)
("INACTIVE" :foreground "magenta" :weight bold)
("SOMEDAY" :foreground "cyan" :weight bold)
("CANCELLED" :foreground "forest green" :weight bold)
("MEETING" :foreground "forest green" :weight bold)))
("CANCELLED" :foreground "forest green" :weight bold)))
;; Auto-update tags whenever the state is changed
(setq org-todo-state-tags-triggers
'(("CANCELLED" ("CANCELLED" . t))
Expand All @@ -61,7 +67,12 @@
("SOMEDAY" ("WAITING") ("INACTIVE") ("SOMEDAY" . t))
(done ("WAITING") ("INACTIVE") ("SOMEDAY"))
("TODO" ("WAITING") ("CANCELLED") ("INACTIVE") ("SOMEDAY"))
("TASK" ("WAITING") ("CANCELLED") ("INACTIVE") ("SOMEDAY"))
("NEXT" ("WAITING") ("CANCELLED") ("INACTIVE") ("SOMEDAY"))
("PROJ" ("WAITING") ("CANCELLED") ("INACTIVE") ("SOMEDAY"))
("AMOTIVATOR" ("WAITING") ("CANCELLED") ("INACTIVE") ("SOMEDAY"))
("TMOTIVATOR" ("WAITING") ("CANCELLED") ("INACTIVE") ("SOMEDAY"))
("CMOTIVATOR" ("WAITING") ("CANCELLED") ("INACTIVE") ("SOMEDAY"))
("DONE" ("WAITING") ("CANCELLED") ("INACTIVE") ("SOMEDAY"))))

(defun gs/mark-next-done-parent-tasks-todo ()
Expand All @@ -77,7 +88,8 @@
(while (org-up-heading-safe)
(when (member (nth 2 (org-heading-components)) (list "NEXT" "DONE"))
(org-todo "TODO")))))))
(add-hook 'org-after-todo-state-change-hook 'gs/mark-next-done-parent-tasks-todo 'append)
;; Note: I want to disable this for now
;; (add-hook 'org-after-todo-state-change-hook 'gs/mark-next-done-parent-tasks-todo 'append)

;; == Capture Mode Settings ==
;; Define the custum capture templates
Expand All @@ -87,7 +99,7 @@
("b" "Blank" entry (file org-default-notes-file)
"* %?\n%u")
("m" "Meeting" entry (file org-default-notes-file)
"* MEETING with %? :MEETING:\n" :clock-in t :clock-resume t)
"* Meeting with %? :MEETING:\n" :clock-in t :clock-resume t)
("d" "Diary" entry (file+datetree "~/org/diary.org")
"* %?\n%U\n" :clock-in t :clock-resume t)
("D" "Daily Log" entry (file "~/org/daily-log.org")
Expand Down Expand Up @@ -125,7 +137,7 @@
;; == Habits ==
(require 'org-habit)
(add-to-list 'org-modules 'org-habit)
(setq org-habit-graph-column 48)
(setq org-habit-graph-column 44)
(setq org-habit-show-habits-only-for-today t)

;; == Checklists ==
Expand All @@ -137,6 +149,10 @@

;;;; bh/helper-functions

(defun gs/is-project-p ()
"A task with a 'PROJ' keyword"
(member (nth 2 (org-heading-components)) '("PROJ")))

(defun bh/is-project-p ()
"Any task with a todo keyword subtask."
(save-restriction
Expand All @@ -153,6 +169,28 @@
(setq has-subtask t))))
(and is-a-task has-subtask))))

(defun gs/find-project-task ()
"Any task with a todo keyword that is in a project subtree"
(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)) '("PROJ"))
(setq parent-task (point))))
(goto-char parent-task)
parent-task)))

(defun gs/is-project-subtree-p ()
"Any task with a todo keyword that is in a project subtree.
Callers of this function already widen the buffer view."
(let ((task (save-excursion (org-back-to-heading 'invisible-ok)
(point))))
(save-excursion
(gs/find-project-task)
(if (equal (point) task)
nil t))))


(defun bh/find-project-task ()
"Move point to the parent (project) task if any."
(save-restriction
Expand Down
4 changes: 4 additions & 0 deletions config/init-10-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
;; No Backup Files
(setq make-backup-files nil)

;; Save more 'recent files'
(setq recentf-max-menu-items 127)
(setq recentf-max-saved-items 127)

;; initial window
(setq initial-frame-alist
'((width . 102) ; characters in a line
Expand Down
21 changes: 20 additions & 1 deletion config/init-31-doc-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
(add-to-list 'org-latex-classes
(add-to-list 'org-latex-classes
'("mitthesis"
"\\documentclass[12pt,twoside]{mitthesis}"
("\\chapter{%s}" . "\\chapter*{%s}")
Expand All @@ -136,6 +136,24 @@
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
(add-to-list 'org-latex-classes
'("annotatedbib"
"\\documentclass[10pt,oneside]{article}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")))
(add-to-list 'org-latex-classes
'("ieeetran"
"\\documentclass{IEEEtran}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")))
)

(setq org-highlight-latex-and-related '(latex))
Expand Down Expand Up @@ -179,6 +197,7 @@
"c" 'org-agenda-goto-calendar
"i" 'org-agenda-clock-in
"o" 'org-agenda-clock-out
"E" 'org-agenda-entry-text-mode
)
(general-define-key
:keymaps 'org-agenda-mode-map
Expand Down

0 comments on commit 615c188

Please sign in to comment.