alphapapa / alphapapa/org-super-agenda

Doomemacs config example for grouping by tags as well as projects (based on the file location)

Open
#282 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
1.5k
Forks
107
PR merge metrics
No merged PRs in 30d

Description

Hello there, I found a few mentions here and there that it's not yet possible to dynamically group tasks based on their parent with custom ordering so I came up with my own. Here's an example for all tasks, but you can also reuse the functions to make a dedicated command for viewing project-specific stuff.

I'm using PARA method for my notes, so all projects tasks that I want to group are located in the `projects/` directory. For each project I may have a few tasks, so it is nice to have an overview on what yet I have to do for them

```
(defun my/file-ordering (file &optional default)
"Return numeric ORDERING property found in FILE.
If the file has no #+PROPERTY: ORDERING line, return DEFAULT
(or 10 if DEFAULT is nil)."
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(if (re-search-forward
"^#\\+PROPERTY:[ \t]+\\(?:[^ \t]+[ \t]+\\)*ORDERING[ \t]+\\([0-9]+\\)"
nil t)
(string-to-number (match-string 1))
(or default 200))))

(defun my/file-title (file)
"Return #+TITLE of FILE, or its base name if no title."
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
;; case-insensitive search for ‘#+title: …’
(if (re-search-forward "^#\\+title:[ \t]+\\(.+\\)$" nil t)
(string-trim (match-string 1))
(file-name-base file))))

(defun my/generate-project-groups ()
"Return a list of org-super-agenda groups for every file in projects/."
(let* ((project-dir (expand-file-name "projects/" org-directory))
(org-directory (file-name-as-directory project-dir))
groups)
(dolist (file (directory-files-recursively project-dir "\\.org$"))
(let* ((order (my/file-ordering file 1000))
(name (file-name-base file))
(f file)) ; close over FILE safely
(push (list :name (my/file-title file)
:order order
:file-path (regexp-quote (expand-file-name file))) ; must be string/regexp
groups)))
;; org-super-agenda uses the lowest :order first; sort for sanity
(sort groups (lambda (a b) (< (plist-get a :order)
(plist-get b :order))))
groups))

(use-package! org-super-agenda
:after org-agenda
:config
(org-super-agenda-mode)
(setq org-agenda-custom-commands
'(("n" "Super view"
((agenda "" ((org-agenda-span 'day)
(org-super-agenda-groups
'((:name "Today"
:time-grid t
:date today
:todo "TODAY"
:scheduled today
:order 1)))))
(alltodo "" ((org-agenda-overriding-header "")
(org-super-agenda-groups
(append
(my/generate-project-groups)
'(
;; Scheduled tasks
(:name "Next to do"
:todo "NEXT"
:order 1)
(:name "Due Today"
:deadline today
:order 2)
(:name "Due Soon"
:deadline future
:order 3)
(:name "Overdue"
:deadline past
:order 4)

;; Tagged work tasks
(:name "Work high priority"
:and (:tag "work"
:priority "A")
:order 10)
(:name "All Work"
:tag "work"
:order 11)

;; Personal stuff
(:name "Personal"
:tag "personal"
:order 20)

(:name "Home"
:tag "home"
:order 21)

;; Projects
(:name "Project ideas"
:todo "PROJ"
:order 30)

;; Specific tags
(:name "Notes"
:tag "notes"
:order 50)
(:name "Emacs"
:tag "Emacs"
:order 51)

;; Discard
(:discard (:tag ("Chore" "Routine" "Daily")))))))))))))
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.