From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: sorting entries on date created? Date: Wed, 6 May 2009 12:19:39 +0200 Message-ID: <7217648F-CC0D-4C63-A2B6-74790219AC92@gmail.com> References: <87prevbein.wl%MarkoSchuetz@web.de> <8410.1241026914@alphaville.usa.hp.com> <4F34046E-A8EF-4A08-9D8F-C0F80CAE9DE0@gmail.com> Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1eEA-0002Qv-Gd for emacs-orgmode@gnu.org; Wed, 06 May 2009 06:19:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1eE5-0002Os-Nl for emacs-orgmode@gnu.org; Wed, 06 May 2009 06:19:50 -0400 Received: from [199.232.76.173] (port=56468 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1eE5-0002Ol-Hz for emacs-orgmode@gnu.org; Wed, 06 May 2009 06:19:45 -0400 Received: from mail-ew0-f162.google.com ([209.85.219.162]:35898) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M1eE4-0001sd-Pb for emacs-orgmode@gnu.org; Wed, 06 May 2009 06:19:45 -0400 Received: by ewy6 with SMTP id 6so5970846ewy.42 for ; Wed, 06 May 2009 03:19:44 -0700 (PDT) In-Reply-To: <4F34046E-A8EF-4A08-9D8F-C0F80CAE9DE0@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: Org Mode Mailing List On May 6, 2009, at 10:11 AM, Carsten Dominik wrote: > > On Apr 29, 2009, at 7:41 PM, Nick Dokos wrote: > >> Marko Sch=FCtz wrote: >> >>> I use remember to add todo entries. Mine look like this >>> >>> ** TODO kpdf as standard pdf viewer from auctex >>> [2008-07-19 Sat] >>> >>> where the inactive timestamp is added at creation. >>> >>> I'd like to use org-sort to sort such entries by creation date. I'd >>> assume I could use sorting-type ?f with a suitable getkey-func. =20 >>> So, is >>> there already a function in org that I could use to extract this =20 >>> date? >>> >> >> Not sure if this helps (it does not answer your question directly): >> >> There are two places in org-sort-entries-or-items (which is called by >> org-sort under the conditions at hand) where a regexp, org-ts-=20 >> regexp, is >> used when sorting-type is selected to be ?t: one is for when you are >> sorting plain lists and the other is when you are sorting top-level >> entries or the active region. If you change the relevant instance of >> org-ts-regexp to org-ts-regexp-both, it will match both active and >> inactive timestamps and sort appropriately. I have not tried to =20 >> figure >> out what happens if there are multiple timestamps, active or =20 >> inactive, >> in an entry. But if you just have a single inactive timestamp per =20 >> entry, >> as you have indicated above, that should work. > > Hi > > the real problem is to find the correct time stamp even in entries > that have multiple time stamps, just as Nick is saying. > > Your best bet will indeed be to write a custom sorting function > for ?f, because the way this function has to be written depends > on how your entries look. > > For example, if we assume that the creation time is the first > inactive time stamp that is at the beginning of a line (to exclude > things like a CLOSED time stamp), you could use > > (defun sort-by-creation-time () > (let ((end (save-excursion (outline-next-heading) (point)))) > (if (re-search-forward (concat "^[ \t]*\\[" org-ts-regexp1 "\\]") > end t) > (time-to-seconds (org-time-string-to-time (match-string 0))) > (time-to-seconds now)))) > > > HTH > > - Carsten > Time sorting is now improved, with the following new sorting methods: t By date/time, either the first active time stamp in the entry, or, =20= if none exist, by the first inactive one. In items, only the first line will be chekced. s By the scheduled date/time. d By deadline date/time. c By creation time, which is assumed to be the first inactive time =20 stamp at the beginning of a line. HTH - Carsten