Thanks Terry - an early Christmas present, I didn't know there was such a 
thing as a c.sortSiblings function so thanks for that!

IH

On Tuesday, 20 December 2016 20:26:35 UTC, Terry Brown wrote:
>
> Hi,
>
> You could avoid renaming the nodes with something like this, untested, 
> just copy/pasting your code:
>
> def datesort(p):
>     datestamp='0000000000'
>
>     if '<' and '>' in p.b: # check to see if there is at least one likely 
> datestamp
>         i = p.b.find("<") #get the index of the beginning of datestamp
>         j = p.b.find(">") # get the index of the end of the datestamp
>         datestamp=p.b[(i+1):j]  # use indices to grab the date
>
>     return datestamp
>
> c.sortSiblings(key=datesort)
>
> Cheers -Terry
>
> ------------------------------
> *From:* Israel Hands <alis...@mcgh.ee <javascript:>>
> *To:* leo-editor <leo-e...@googlegroups.com <javascript:>> 
> *Cc:* terry_...@yahoo.com <javascript:>
> *Sent:* Tuesday, December 20, 2016 1:39 PM
> *Subject:* Re: Org Mode File - Node sorted by time stamp
>
> I think I'll try option one - I'm a slow and clunky coder - I've written 
> this which tests the next node for the telltale <brackets> and grabs the 
> datestamp. It then renames the node with the datestamp at the beginning of 
> the node name. 
> The plan is to rename all the nodes with datestamps in the body of the 
> text, then use Leo commands to sort the nodes then un-name them, if you see 
> what I mean. I'll need to deal with the deadline datestamp - I'll think on 
> that. If you see any obvious improvements do let me know.
>
> p=p.moveToNext() # drop down to next node
> separator='||' # make a separator
> if '<' and '>' in p.b: # check to see if there is at least one likely 
> datestamp
>     i = p.b.find("<") #get the index of the beginning of datestamp
>     j = p.b.find(">") # get the index of the end of the datestamp
>     datestamp=p.b[(i+1):j]  # use indices to grab the date
>     newhead=datestamp+separator+p.h #make a new header including the 
> datestam and separator
>     c.setHeadString(p,newhead) #write the new header.
>
> Thanks for the encouragement - If I get a working solution I'll let you 
> know!
>
> IH
>
> On Tuesday, 20 December 2016 16:21:48 UTC, Terry Brown wrote:
>
> Ok, I haven't used org mode import.
>
> Seems like you wouldn't want the timestamps in the header, all you'd see 
> in the tree view would be the timestamps.
>
> Two possible approaches:
>
>  - write a small piece of code to sort the nodes based on the timestamps 
> in the body content.
>  - import the org file taking advantage of Leo's todo plugin, which has 
> date due fields and ui options to sort by them
>
> Cheers -Terry
>
> ------------------------------
> *From:* Israel Hands <alis...@mcgh.ee>
> *To:* leo-editor <leo-e...@googlegroups.com> 
> *Cc:* terry_...@yahoo.com
> *Sent:* Tuesday, December 20, 2016 10:01 AM
> *Subject:* Re: Org Mode File - Node sorted by time stamp
>
>
> Thanks Terry and Rob!
>
> I realise I wasn't clear enough in my original post. Org mode allows todo 
> items to be entered into a file in any order but they can include a 
> timestamp of their 'scheduled' time (and indeed a separate deadline 
> timestamp).  In the orgmode Agenda view the items are then inserted in to a 
> linear calendar, turning the unordered org file into a powerful 
> calendar/todo list.
>
> So one of my org mode items is -  Breakfast with James - it has a 
> scheduled time and I have chosen to set a deadline.  When I choose Agenda 
> view in orgmode I see the item has a deadline in today's date and the item 
> itself appears in the calendar for tomorrow.
> Imported into leo I get a nice node with the headline - Breakfast with 
> James -  and the body text is the two time stamps - the deadline is Tuesday 
> the 20th (to remind me it is tomorrow) and then the scheduled time of the 
> event Wednesday the 21st at 10am.  The node body looks like this = 
>
>    DEADLINE: <2016-12-20 Tue 09:00>
> <2016-12-21 Wed 10:00>
>
> However the nodes are listed according to their place in the orgmode file 
> (in creation order) rather than schedule order. 
> I guess it would require digging out these scheduled times and maybe 
> writing them into the header which would then make it easy to sort the 
> nodes.
>
> Anyway thanks for your attention.
> IH
>
>
> On Tuesday, 20 December 2016 15:07:39 UTC, Terry Brown wrote:
>
> Depends what you mean by timestamps.  If you mean a piece of text in the 
> header, one of the Outline -> Sort commands should work.
>
> If you mean sort by the internal "gnx" ID attribute of the nodes, which 
> contains timestamp information, I don't think there's a command to actually 
> re-order nodes on that basis.  But there is a command
> find-quick-timeline which displays all the nodes in the outline in the Nav 
> pane, ordered most recently created to oldest.  Maybe that helps?  
> find-quick-timeline 
> uses the gnx info.
>
> Cheers -Terry
>
> ------------------------------
> *From:* Israel Hands <alis...@mcgh.ee>
> *To:* leo-editor <leo-e...@googlegroups.com> 
> *Sent:* Tuesday, December 20, 2016 7:23 AM
> *Subject:* Org Mode File - Node sorted by time stamp
>
> I use OrgMode's Agenda view as my basic calendar and it's great to be able 
> to import the org files into leo, is there a way of sorting the imported 
> nodes by time stamp, other than writing a bit of code to accomplish the 
> task?
>
> ta
>
> Al
> -- 
> You received this message because you are subscribed to the Google Groups 
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to leo-editor+...@ googlegroups.com.
> To post to this group, send email to leo-e...@googlegroups.com.
>
> Visit this group at https://groups.google.com/ group/leo-editor 
> <https://groups.google.com/group/leo-editor>.
> For more options, visit https://groups.google.com/d/ optout 
> <https://groups.google.com/d/optout>.
>
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to leo-editor+...@ googlegroups.com.
> To post to this group, send email to leo-e...@googlegroups.com.
> Visit this group at https://groups.google.com/ group/leo-editor 
> <https://groups.google.com/group/leo-editor>.
> For more options, visit https://groups.google.com/d/ optout 
> <https://groups.google.com/d/optout>.
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to leo-editor+...@googlegroups.com <javascript:>.
> To post to this group, send email to leo-e...@googlegroups.com 
> <javascript:>.
> Visit this group at https://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to