From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Harkins Subject: Re: Agenda TODO sorting by date Date: Sun, 04 Mar 2012 14:59:52 +0800 Message-ID: <87r4x8yhp3.wl%jamshark70@dewdrop-world.net> References: <87pqcu4duz.wl%jamshark70@dewdrop-world.net> <87399qielx.fsf@norang.ca> <87399pzm9w.wl%jamshark70@dewdrop-world.net> <87ty2533ti.fsf@norang.ca> <87vcmlxe8h.wl%jamshark70@dewdrop-world.net> <87fwdpj8b0.fsf@norang.ca> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S45QU-0006Hy-R0 for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 02:00:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S45QS-0001vC-Qp for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 02:00:14 -0500 Received: from mail-pz0-f52.google.com ([209.85.210.52]:63189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S45QS-0001uy-I2 for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 02:00:12 -0500 Received: by dadp12 with SMTP id p12so3303092dad.39 for ; Sat, 03 Mar 2012 23:00:10 -0800 (PST) In-Reply-To: <87fwdpj8b0.fsf@norang.ca> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bernt Hansen Cc: emacs-orgmode@gnu.org At Sat, 03 Mar 2012 23:31:47 -0500, Bernt Hansen wrote: > >> (defun bh/agenda-sort-by-heading-date (a b) > >> "Sorting strategy for agenda items. > >> Late deadlines first, then scheduled, then non-late deadlines" > > Oops... this description is all wrong - since I gutted my existing > sorting function to try this... I'll let you fix that :) :) I wondered about that. There are non-timestamped TODO items in my org files, so I needed to hack a little further. The version below is working beautifully. Thanks for all the help! I doubt I would have figured this out very quickly. James (defun bh/agenda-sort-by-heading-date (a b) "Sorting strategy for agenda items. Timestamped entries first (ascending order), then non-timestamped" ;(message "Heading a: <%s>" a) ;(message "Heading b: <%s>" b) (let* ((date-regexp "\\(\\<[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\\) ") date-a date-b) (if (string-match date-regexp a) (setq date-a (match-string 1 a)) (setq date-a "ZZZZZZ") ; clunko workaround to push dateless entries last ) (if (string-match date-regexp b) (setq date-b (match-string 1 b)) (setq date-b "ZZZZZZ") ) (cond ((string< date-a date-b) -1) ((string< date-b date-a) +1) ;((t nil)) ))) -- James Harkins /// dewdrop world jamshark70@dewdrop-world.net http://www.dewdrop-world.net "Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman blog: http://www.dewdrop-world.net/words audio clips: http://www.dewdrop-world.net/audio more audio: http://soundcloud.com/dewdrop_world/tracks