From 68e6c08c17fade8346b34e5a19b9a2f2aff50e61 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 27 Mar 2009 17:50:21 +0100 Subject: [PATCH] Agenda: Introduce user-defined sorting operators. The new variable `org-agenda-cmp-user-defined' can contain a function to test how two entries should be compared during sorting. user-defined-up and user-defined-down can then be part of any sorting strategy. --- doc/org.texi | 4 +++- lisp/ChangeLog | 5 +++++ lisp/org-agenda.el | 51 +++++++++++++++++++++++++++++++--------------- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 6cbf25819..7f4162850 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -6570,7 +6570,9 @@ overdue scheduled or deadline items. @item For the TODO list, items remain in the order of categories, but within each category, sorting takes place according to priority -(@pxref{Priorities}). +(@pxref{Priorities}). The priority used for sorting derives from the +priority cookie, with additions depending on how close an item is to its due +or scheduled date. @item For tags matches, items are not sorted at all, but just appear in the sequence in which they are found in the agenda files. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 72690f86d..bcca0012c 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2009-03-27 Carsten Dominik + * org-agenda.el (org-agenda-cmp-user-defined): New option. + (org-sorting-choice, org-agenda-sorting-strategy): Add the new + sorting options. + (org-entries-lessp): Apply the new sorting option. + * org.el (org-block-todo-from-children-or-siblings): Fix bug in blocker code, when an older sibling has children. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index d013e5c34..5b16f11ba 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -188,7 +188,8 @@ you can \"misuse\" it to also add other text to the header. However, (const tag-down) (const tag-up) (const priority-up) (const priority-down) (const todo-state-up) (const todo-state-down) - (const effort-up) (const effort-down)) + (const effort-up) (const effort-down) + (const user-defined-up) (const user-defined-down)) "Sorting choices.") (defconst org-agenda-custom-commands-local-options @@ -861,20 +862,22 @@ This is a list of symbols which will be used in sequence to determine if an entry should be listed before another entry. The following symbols are recognized: -time-up Put entries with time-of-day indications first, early first -time-down Put entries with time-of-day indications first, late first -category-keep Keep the default order of categories, corresponding to the - sequence in `org-agenda-files'. -category-up Sort alphabetically by category, A-Z. -category-down Sort alphabetically by category, Z-A. -tag-up Sort alphabetically by last tag, A-Z. -tag-down Sort alphabetically by last tag, Z-A. -priority-up Sort numerically by priority, high priority last. -priority-down Sort numerically by priority, high priority first. -todo-state-up Sort by todo state, tasks that are done last. -todo-state-down Sort by todo state, tasks that are done first. -effort-up Sort numerically by estimated effort, high effort last. -effort-down Sort numerically by estimated effort, high effort first. +time-up Put entries with time-of-day indications first, early first +time-down Put entries with time-of-day indications first, late first +category-keep Keep the default order of categories, corresponding to the + sequence in `org-agenda-files'. +category-up Sort alphabetically by category, A-Z. +category-down Sort alphabetically by category, Z-A. +tag-up Sort alphabetically by last tag, A-Z. +tag-down Sort alphabetically by last tag, Z-A. +priority-up Sort numerically by priority, high priority last. +priority-down Sort numerically by priority, high priority first. +todo-state-up Sort by todo state, tasks that are done last. +todo-state-down Sort by todo state, tasks that are done first. +effort-up Sort numerically by estimated effort, high effort last. +effort-down Sort numerically by estimated effort, high effort first. +user-defined-up Sort according to `org-agenda-cmp-user-defined', high last. +user-defined-down Sort according to `org-agenda-cmp-user-defined', high first. The different possibilities will be tried in sequence, and testing stops if one comparison returns a \"not-equal\". For example, the default @@ -905,6 +908,16 @@ Custom commands can bind this variable in the options section." (cons (const :tag "Strategy for Tags matches" tags) (repeat ,org-sorting-choice))))) +(defcustom org-agenda-cmp-user-defined nil + "A function to define the comparison `user-defined'. +This function must receive two arguments, agenda entry a and b. +If a>b, return +1. If a