emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* sorting entries on date created?
@ 2009-04-29 16:39 Marko Schütz
  2009-04-29 17:41 ` Nick Dokos
  0 siblings, 1 reply; 4+ messages in thread
From: Marko Schütz @ 2009-04-29 16:39 UTC (permalink / raw)
  To: Org Mode Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 414 bytes --]

Dear All,

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. So, is
there already a function in org that I could use to extract this date?

Thanks,

Marko

[-- Attachment #1.2: Type: application/pgp-signature, Size: 194 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sorting entries on date created?
  2009-04-29 16:39 sorting entries on date created? Marko Schütz
@ 2009-04-29 17:41 ` Nick Dokos
  2009-05-06  8:11   ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Dokos @ 2009-04-29 17:41 UTC (permalink / raw)
  To: Marko =?ISO-8859-1?Q?Sch=FCtz?=; +Cc: Org Mode Mailing List

Marko Schütz <MarkoSchuetz@web.de> 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. So, is
> there already a function in org that I could use to extract this 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-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 figure
out what happens if there are multiple timestamps, active or inactive,
in an entry. But if you just have a single inactive timestamp per entry,
as you have indicated above, that should work.

HTH,
Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sorting entries on date created?
  2009-04-29 17:41 ` Nick Dokos
@ 2009-05-06  8:11   ` Carsten Dominik
  2009-05-06 10:19     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2009-05-06  8:11 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Org Mode Mailing List


On Apr 29, 2009, at 7:41 PM, Nick Dokos wrote:

> Marko Schütz <MarkoSchuetz@web.de> 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. So,  
>> is
>> there already a function in org that I could use to extract this  
>> 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- 
> 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 figure
> out what happens if there are multiple timestamps, active or inactive,
> in an entry. But if you just have a single inactive timestamp per  
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sorting entries on date created?
  2009-05-06  8:11   ` Carsten Dominik
@ 2009-05-06 10:19     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2009-05-06 10:19 UTC (permalink / raw)
  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ütz <MarkoSchuetz@web.de> 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.  
>>> So, is
>>> there already a function in org that I could use to extract this  
>>> 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- 
>> 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  
>> figure
>> out what happens if there are multiple timestamps, active or  
>> inactive,
>> in an entry. But if you just have a single inactive timestamp per  
>> 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,  
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  
stamp
     at the beginning of a line.


HTH

- Carsten

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-05-06 10:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-29 16:39 sorting entries on date created? Marko Schütz
2009-04-29 17:41 ` Nick Dokos
2009-05-06  8:11   ` Carsten Dominik
2009-05-06 10:19     ` Carsten Dominik

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).