From: "Emin.shopper Martinian.shopper" <emin.shopper@gmail.com>
To: Bernt Hansen <bernt@norang.ca>
Cc: emacs-orgmode@gnu.org
Subject: Re: How do you control sorting in org agenda?
Date: Fri, 21 May 2010 08:36:19 -0400 [thread overview]
Message-ID: <AANLkTikT4XaIbQ3uS0zZHW2yEa1civgIGfBPd11482Ka@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikoBIsHX0r1ugoguN824NHlz49fquzvHbC0NzZW@mail.gmail.com>
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)))
>
prev parent reply other threads:[~2010-05-21 12:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTikT4XaIbQ3uS0zZHW2yEa1civgIGfBPd11482Ka@mail.gmail.com \
--to=emin.shopper@gmail.com \
--cc=bernt@norang.ca \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).