Might as well brag about this, since I’m inordinately proud (I become an #elisp hacker about once every two or three years). I love #emacs #org-mode, but I don’t love what it does with todo entries (highest-priority, longest-scheduled first). For me, if something’s been at priority A for 280 days, it’s not that high-priority (but still higher than anything at priority B). I want highest-priority, most-recently-scheduled first, in the time-honored tradition of ignoring things in the hope they’ll go away.
Here it is.
(defun my-org-agenda-todo-sort (a b)
"Function should only sort TODO items; since I can't return ``unsortable'' for things that don't compare, I just
return 0 and hope for the best. Seems to be working so far. Higher-priority and more-recently-scheduled items
have higher urgency."
(if (string-match "\\(Sched\\.\\s-*\\([0-9]+\\)x\\|Scheduled\\):\\s-+\\S-+ \\[#\\([ABC]\\)\\]" a)
(let ((a-sched-days (string-to-number (if (null (match-string 2 a)) "0" (match-string 2 a))))
(a-priority (match-string 3 a)))
(if (string-match "\\(Sched\\.\\s-*\\([0-9]+\\)x\\|Scheduled\\):\\s-+\\S-+ \\[#\\([ABC]\\)\\]" b)
(let ((b-sched-days (string-to-number (if (null (match-string 2 b)) "0" (match-string 2 b))))
(b-priority (match-string 3 b)))
;(message "Agenda item a of type %s: %s" (type-of a) a)
;(message "Agenda item b of type %s: %s" (type-of b) b)
;(message "a-priority: %s; b-priority: %s; a-sched-days: %s; b-sched-days: %s"
; a-priority b-priority a-sched-days b-sched-days)
(cond ((string< a-priority b-priority) 1)
((string> a-priority b-priority) -1)
(t (cond ((< a-sched-days b-sched-days) 1)
((> a-sched-days b-sched-days) -1)
(t 0)))))
0
)
)
0
)
)
(setq org-agenda-cmp-user-defined 'my-org-agenda-todo-sort)
(setq org-agenda-sorting-strategy '((agenda habit-down time-up user-defined-down category-keep)
(todo urgency-down category-keep)
(tags urgency-down category-keep)
(search category-keep)))
Update: Ok, that was stupid. Here’s a more readable version:
https://gist.github.com/JohnL4/4ddd2ec185b8a9b948db6d62edb9d32d
@herereadthis.blog
Oh, c'mon, Mastodon. You recognize the font change and can preserve whitespace but can't preserve line breaks?
LikeLike
Remote Reply
Original Comment URL
Your Profile
Why do I need to enter my profile?
This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.
By entering your profile, we can send you to your account where you can complete this action.
@herereadthis.blog @sacha Thank you for this. I've been wanting this feature for like forever but didn't have the elisp-fu sufficient to do anything about it. 🙂
LikeLike
Remote Reply
Original Comment URL
Your Profile
Why do I need to enter my profile?
This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.
By entering your profile, we can send you to your account where you can complete this action.
Sure! 🙂 Like everything I do in emacs, it’s a foul hack, but it does what I want.
LikeLike