From 9457b3a4c7320672ea0b445f93b4d55781967d16 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 18 Nov 2018 07:10:04 +0100 Subject: [PATCH] Create a more beautiful (and hopefully more helpful) agenda view --- configuration.org | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/configuration.org b/configuration.org index 5f0ba62..597d6b5 100644 --- a/configuration.org +++ b/configuration.org @@ -945,6 +945,43 @@ TODO: What is FIELD for?" (or (abbrev--before-point) (yasnippet-can-fire-p))) #+END_SRC +** Filter out tasks from the Org agenda if they have a specific priority + +The whole idea comes from [[https://blog.aaronbieber.com/2016/09/24/an-agenda-for-life-with-org-mode.html][here]], which i use almost verbatim. This is also the reason it has the +~air-~ prefix. + +#+BEGIN_SRC emacs-lisp +(defun air-org-skip-subtree-if-priority (priority) + "Skip an agenda subtree if it has a priority of PRIORITY. + +PRIORITY may be one of the characters ?A, ?B, or ?C." + (let ((subtree-end (save-excursion (org-end-of-subtree t))) + (pri-value (* 1000 (- org-lowest-priority priority))) + (pri-current (org-get-priority (thing-at-point 'line t)))) + (if (= pri-value pri-current) + subtree-end + nil))) +#+END_SRC + +** Filter out habits from the Org agenda + +#+BEGIN_SRC emacs-lisp +(defun air-org-skip-subtree-if-habit () + "Skip an agenda entry if it has a STYLE property equal to \"habit\"." + (let ((subtree-end (save-excursion (org-end-of-subtree t)))) + (if (string= (org-entry-get nil "STYLE") "habit") + subtree-end + nil))) +#+END_SRC + +** Wrapper around ~org-agenda~ to open my own custom list + +#+BEGIN_SRC emacs-lisp +(defun gpolonkai/org-agenda-list (&optional arg) + (interactive "P") + (org-agenda arg "c")) +#+END_SRC + * UI preferences ** Tweak window chrome @@ -2428,7 +2465,18 @@ This is a big one; I use a lot of customisation here. org-refile-targets '((org-agenda-files :maxlevel . 3)) org-refile-use-outline-path 'file org-outline-path-complete-in-steps nil - org-refile-allow-creating-parent-nodes 'confirm) + org-refile-allow-creating-parent-nodes 'confirm + org-agenda-custom-commands '(("c" "Simple agenda view" ((tags "PRIORITY=\"A\"" + ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) + (org-agenda-overriding-header "High priority unfinished tasks"))) + (agenda "") + (alltodo "" + ((org-agenda-skip-function + '(or (air-org-skip-subtree-if-habit) + (air-org-skip-subtree-if-priority ?A) + (org-agenda-skip-if nil '(scheduled deadline)))) + (org-agenda-overriding-header "ALL normal priority tasks")))) + ((org-agenda-compact-blocks t))))) :config ;; Load the markdown exporter (require 'ox-md) @@ -2450,7 +2498,7 @@ This is a big one; I use a lot of customisation here. (add-hook 'ediff-unselect-hook 'f-ediff-org-fold-tree) :bind (:map gpolonkai/pers-map - ("a" . org-agenda-list) + ("a" . gpolonkai/org-agenda-list) ("c" . org-capture) ("l" . org-store-link) :map org-mode-map