* How do you control sorting in org agenda?
@ 2010-05-13 20:47 Emin.shopper Martinian.shopper
2010-05-13 20:59 ` Bernt Hansen
0 siblings, 1 reply; 4+ messages in thread
From: Emin.shopper Martinian.shopper @ 2010-05-13 20:47 UTC (permalink / raw)
To: emacs-orgmode
Dear Experts,
How do you control sorting in org agenda? For example, if I have two
items that have been assigned the same priority level of #A how do I
control how they are sorted?
Thanks,
-Emin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How do you control sorting in org agenda?
2010-05-13 20:47 How do you control sorting in org agenda? Emin.shopper Martinian.shopper
@ 2010-05-13 20:59 ` Bernt Hansen
2010-05-17 11:50 ` Emin.shopper Martinian.shopper
0 siblings, 1 reply; 4+ messages in thread
From: Bernt Hansen @ 2010-05-13 20:59 UTC (permalink / raw)
To: Emin.shopper Martinian.shopper; +Cc: emacs-orgmode
"Emin.shopper Martinian.shopper" <emin.shopper@gmail.com> writes:
> Dear Experts,
>
> How do you control sorting in org agenda? For example, if I have two
> items that have been assigned the same priority level of #A how do I
> control how they are sorted?
See the variable org-agenda-sorting-strategy.
-Bernt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How do you control sorting in org agenda?
2010-05-13 20:59 ` Bernt Hansen
@ 2010-05-17 11:50 ` Emin.shopper Martinian.shopper
2010-05-21 12:36 ` Emin.shopper Martinian.shopper
0 siblings, 1 reply; 4+ messages in thread
From: Emin.shopper Martinian.shopper @ 2010-05-17 11:50 UTC (permalink / raw)
To: Bernt Hansen; +Cc: emacs-orgmode
On Thu, May 13, 2010 at 4:59 PM, Bernt Hansen <bernt@norang.ca> wrote:
> "Emin.shopper Martinian.shopper" <emin.shopper@gmail.com> writes:
>
>
> See the variable org-agenda-sorting-strategy.
>
> -Bernt
Thanks for the pointer. I put the following in my .emacs file and the
I change my prioritized items to things like TODO [#A]-01 foo, TODO
[#A]-02 bar, etc. and things sort as I wanted.
(defun org-cmp-title (a b)
"Compare the titles of string A and B"
(cond ((string-lessp a b) -1)
((string-lessp b a) +1)
(t nil)))
(setq org-agenda-cmp-user-defined 'org-cmp-title)
(setq org-agenda-sorting-strategy
'((agenda habit-down time-up priority-down category-keep)
(todo priority-down user-defined-up category-keep)
(tags priority-down category-keep)
(search category-keep)))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How do you control sorting in org agenda?
2010-05-17 11:50 ` Emin.shopper Martinian.shopper
@ 2010-05-21 12:36 ` Emin.shopper Martinian.shopper
0 siblings, 0 replies; 4+ messages in thread
From: Emin.shopper Martinian.shopper @ 2010-05-21 12:36 UTC (permalink / raw)
To: Bernt Hansen; +Cc: emacs-orgmode
It turned out my previous attempt at sorting didn't quite work, here
is an improved version of the hack for anyone else who wants to add
sub-priorities to control sorting of todo items:
(defun org-cmp-sub-priority (a b)
"""Compare the titles of string A and B
This function can be used in the org-agenda-cmp-user-defined variable
and org-agenda-sorting-strategy to compare the sort order of org entries.
It looks for something of the from TODO[<priority>]-<num> where <priority>
is one of #A, #B, #C indicating an org prioity and <num> is a sub-priority
which org doesn't know about but which controls the sorting order. For
example, I have TODO entries like
TODO [#A]-01 foo
TODO [#A]-02 bar
TODO [#A]-03 baz
and use this function to make sure they get sorted properly in the
todo screen of org-agenda.
"""
(let* ((aa (car (last (split-string (substring-no-properties a) "TODO .#."))))
(bb (car (last (split-string (substring-no-properties b) "TODO .#."))))
(use-a (string-match "^.?-[0-9]" aa))
(use-b (string-match "^.?-[0-9]" bb))
)
(cond ((and use-a use-b) ;; check if both aa and bb have a priority
(cond ((string-lessp aa bb) -1) ;; if so, just compare strings
((string-lessp bb aa) +1)
(t nil)))
(use-a -1) ;; a has priority but not b
(use-b +1) ;; b has priority but not a
(t nil)) ;; nobody has priority so don't compare
))
(setq org-agenda-cmp-user-defined 'org-cmp-sub-priority)
(setq org-agenda-sorting-strategy
'((agenda habit-down time-up priority-down category-keep)
(todo priority-down user-defined-up)
(tags priority-down category-keep)
(search category-keep)))
On Mon, May 17, 2010 at 7:50 AM, Emin.shopper Martinian.shopper
<emin.shopper@gmail.com> wrote:
> On Thu, May 13, 2010 at 4:59 PM, Bernt Hansen <bernt@norang.ca> wrote:
>> "Emin.shopper Martinian.shopper" <emin.shopper@gmail.com> writes:
>>
>>
>> See the variable org-agenda-sorting-strategy.
>>
>> -Bernt
>
>
> Thanks for the pointer. I put the following in my .emacs file and the
> I change my prioritized items to things like TODO [#A]-01 foo, TODO
> [#A]-02 bar, etc. and things sort as I wanted.
>
>
> (defun org-cmp-title (a b)
> "Compare the titles of string A and B"
> (cond ((string-lessp a b) -1)
> ((string-lessp b a) +1)
> (t nil)))
>
> (setq org-agenda-cmp-user-defined 'org-cmp-title)
>
> (setq org-agenda-sorting-strategy
> '((agenda habit-down time-up priority-down category-keep)
> (todo priority-down user-defined-up category-keep)
> (tags priority-down category-keep)
> (search category-keep)))
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-21 12:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-13 20:47 How do you control sorting in org agenda? Emin.shopper Martinian.shopper
2010-05-13 20:59 ` Bernt Hansen
2010-05-17 11:50 ` Emin.shopper Martinian.shopper
2010-05-21 12:36 ` Emin.shopper Martinian.shopper
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).