Re: [O] Agenda TODO sorting by date

2012-03-03 Thread James Harkins
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 "ZZ")  ; clunko workaround to push dateless entries 
last
)
(if
(string-match date-regexp b)
(setq date-b (match-string 1 b))
(setq date-b "ZZ")
)
(cond ((string< date-a date-b) -1)
  ((string< date-b date-a) +1)
  ;((t nil))
)))


--
James Harkins /// dewdrop world
jamshar...@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



Re: [O] Agenda TODO sorting by date

2012-03-03 Thread Bernt Hansen
James Harkins  writes:

> At Sat, 03 Mar 2012 14:03:05 -0500,
> Bernt Hansen wrote:
>> I think this works
>> 
>> --8<---cut here---start->8---
>> 
>> (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 :)

Regards,
Bernt


>
>> .
>
> Oops :)  that's what I get for answering e-mail before updating from IMAP.
>
> Thanks for this, will try later. "string-match" -- amazing that none
> of the pages I found by searching for things like "lisp regular
> expression" mentioned this function *at all* ?? I guess a lot of
> programming language or software documentation is like this -- it's
> easy to find what something is called when you already know what it's
> called. Heh. Anyway, learned something, that's good.
>
> Thanks again!!
>
> James



Re: [O] Agenda TODO sorting by date

2012-03-03 Thread James Harkins
At Sat, 03 Mar 2012 14:03:05 -0500,
Bernt Hansen wrote:
> I think this works
> 
> --8<---cut here---start->8---
> 
> (defun bh/agenda-sort-by-heading-date (a b)
>   "Sorting strategy for agenda items.
> Late deadlines first, then scheduled, then non-late deadlines"

> .

Oops :)  that's what I get for answering e-mail before updating from IMAP.

Thanks for this, will try later. "string-match" -- amazing that none of the 
pages I found by searching for things like "lisp regular expression" mentioned 
this function *at all* ?? I guess a lot of programming language or software 
documentation is like this -- it's easy to find what something is called when 
you already know what it's called. Heh. Anyway, learned something, that's good.

Thanks again!!

James


--
James Harkins /// dewdrop world
jamshar...@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



Re: [O] Agenda TODO sorting by date

2012-03-03 Thread James Harkins
At Sat, 3 Mar 2012 08:38:32 -0800,
Alan E. Davis wrote:
> I am definitely not a programmer, and for sure not the one who could guide 
> you on writing a sort
> function.  HOWEVER, emacs has a really nice facility for doing so, if you 
> decide you want to try
> that. 
> 
> I had to write a program to alphabetize a lexical list in Chuukese, in an 
> arbitrary order other
> than standard english alphabetical order.  I had to have guidance, but it was 
> certainly possible,
> even for me.
> 
> Just some encouragement, but it's been many years, and i am unable to offer 
> more than that.
>  
> http://www.gnu.org/software/emacs/manual/html_node/elisp/Sorting.html

Hm, these would sort lines of the buffer after the agenda is created (is there 
a hook in org to do so?), but the idea is to tell org how to sort before 
putting the stuff in the agenda buffer.

I'm looking for a function that will do this -- given:

** DONE PUSH onFailure arg for waitForBoot <2012-01-31 Tue>

and the regexp "<[^>]+>" -- return <2012-01-31 Tue>.

I can find emacs lisp functions for regexp search within a buffer (nope), but 
the point is not to look in a buffer. It's to pass in the source string.

Did several google searches, and couldn't find the magic words (search terms).

Thanks,
James


--
James Harkins /// dewdrop world
jamshar...@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



Re: [O] Agenda TODO sorting by date

2012-03-03 Thread Bernt Hansen
James Harkins  writes:

> At Fri, 02 Mar 2012 21:48:42 -0500,
> Bernt Hansen wrote:
>> You could write a custom sorting function that parses out the date from
>> the heading and compares them.  There may be a better way to do this
>> that I'm not aware of for this.
>> 
>> Set this function up in org-agenda-cmp-user-defined and
>> org-agenda-sorting-strategy to get the results you want.
>
> OK, thanks. I was starting to think it would come to that. Kind of
> surprising this isn't offered out of the box.
>
> I think I need a bit more guidance, from you or someone else.
>
>> parses out the date from the heading
>
> Is there already an org function to do this? C-h a searches on the
> following yielded nothing that seemed interesting.
>
> org.*date.*
> org.*timestamp.*
>
>> compares them
>
> I was about to make that more complicated, but actually string
> comparison should be fine for this. No worries there.
>
> I have done rather little with emacs-lisp so... this is uphill for me. Thanks.

I think this works

--8<---cut here---start->8---

(defun bh/agenda-sort-by-heading-date (a b)
  "Sorting strategy for agenda items.
Late deadlines first, then scheduled, then non-late deadlines"
  (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)
(string-match date-regexp a)
(setq date-a (match-string 1 a))
(string-match date-regexp b)
(setq date-b (match-string 1 b))
(cond ((string< date-a date-b) -1)
  ((string< date-b date-a) +1)
  ((t nil)
  nil)

;;
;; Agenda sorting functions
;;
(setq org-agenda-cmp-user-defined 'bh/agenda-sort-by-heading-date)


(setq org-agenda-custom-commands
  (quote (("x" "Tasks" tags-todo ""
   ((org-agenda-overriding-header "Tasks sorted by date")
(org-agenda-sorting-strategy
 '(user-defined-up)))
--8<---cut here---end--->8---

Then C-c a < x Tag RET 
gives

,
| Tasks sorted by date
|   scratch:TODO Third todo in file <2012-03-28 Wed> 
:Tag:
|   scratch:TODO Second todo in file <2012-03-29 Thu>
:Tag:
|   scratch:TODO First todo in file <2012-03-30 Fri> 
:Tag:
|   scratch:TODO Fourth todo in file <2012-03-31 Sat>
:Tag:
`

HTH,
Bernt



Re: [O] Agenda TODO sorting by date

2012-03-03 Thread Alan E. Davis
I am definitely not a programmer, and for sure not the one who could guide
you on writing a sort function.  HOWEVER, emacs has a really nice facility
for doing so, if you decide you want to try that.

I had to write a program to alphabetize a lexical list in Chuukese, in an
arbitrary order other than standard english alphabetical order.  I had to
have guidance, but it was certainly possible, even for me.

Just some encouragement, but it's been many years, and i am unable to offer
more than that.

http://www.gnu.org/software/emacs/manual/html_node/elisp/Sorting.html

Alan

On Sat, Mar 3, 2012 at 8:23 AM, James Harkins  wrote:

> At Fri, 02 Mar 2012 21:48:42 -0500,
> Bernt Hansen wrote:
> > You could write a custom sorting function that parses out the date from
> > the heading and compares them.  There may be a better way to do this
> > that I'm not aware of for this.
> >
> > Set this function up in org-agenda-cmp-user-defined and
> > org-agenda-sorting-strategy to get the results you want.
>
> OK, thanks. I was starting to think it would come to that. Kind of
> surprising this isn't offered out of the box.
>
> I think I need a bit more guidance, from you or someone else.
>
> > parses out the date from the heading
>
> Is there already an org function to do this? C-h a searches on the
> following yielded nothing that seemed interesting.
>
> org.*date.*
> org.*timestamp.*
>
> > compares them
>
> I was about to make that more complicated, but actually string comparison
> should be fine for this. No worries there.
>
> I have done rather little with emacs-lisp so... this is uphill for me.
> Thanks.
>
> James
>
>
> --
> James Harkins /// dewdrop world
> jamshar...@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
>
>


Re: [O] Agenda TODO sorting by date

2012-03-03 Thread James Harkins
At Fri, 02 Mar 2012 21:48:42 -0500,
Bernt Hansen wrote:
> You could write a custom sorting function that parses out the date from
> the heading and compares them.  There may be a better way to do this
> that I'm not aware of for this.
> 
> Set this function up in org-agenda-cmp-user-defined and
> org-agenda-sorting-strategy to get the results you want.

OK, thanks. I was starting to think it would come to that. Kind of surprising 
this isn't offered out of the box.

I think I need a bit more guidance, from you or someone else.

> parses out the date from the heading

Is there already an org function to do this? C-h a searches on the following 
yielded nothing that seemed interesting.

org.*date.*
org.*timestamp.*

> compares them

I was about to make that more complicated, but actually string comparison 
should be fine for this. No worries there.

I have done rather little with emacs-lisp so... this is uphill for me. Thanks.

James


--
James Harkins /// dewdrop world
jamshar...@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



Re: [O] Agenda TODO sorting by date

2012-03-02 Thread Bernt Hansen
James Harkins  writes:

> Given this:
>
> * Category 1
> ** TODO First todo in file <2012-03-30 Fri>   :Tag:
> ** TODO Second todo in file <2012-03-29 Thu>  :Tag:
> * Category 2
> ** TODO Third todo in file <2012-03-28 Wed>   :Tag:
> ** TODO Fourth todo in file <2012-03-31 Sat>  :Tag:
>
> I do C-c a < M Tag  and get:
>
> Headlines with TAGS match: Tag
> Press `C-u r' to search again with new search string
>   todo_sort:  TODO First todo in file <2012-03-30 Fri> 
> :Tag:
>   todo_sort:  TODO Second todo in file <2012-03-29 Thu>
> :Tag:
>   todo_sort:  TODO Third todo in file <2012-03-28 Wed> 
> :Tag:
>   todo_sort:  TODO Fourth todo in file <2012-03-31 Sat>
> :Tag:
>
> I want to configure a custom agenda command so that I get:
>
> Headlines with TAGS match: Tag
> Press `C-u r' to search again with new search string
>   todo_sort:  TODO Third todo in file <2012-03-28 Wed> 
> :Tag:
>   todo_sort:  TODO Second todo in file <2012-03-29 Thu>
> :Tag:
>   todo_sort:  TODO First todo in file <2012-03-30 Fri> 
> :Tag:
>   todo_sort:  TODO Fourth todo in file <2012-03-31 Sat>
> :Tag:
>
> How do I do this?

You could write a custom sorting function that parses out the date from
the heading and compares them.  There may be a better way to do this
that I'm not aware of for this.

Set this function up in org-agenda-cmp-user-defined and
org-agenda-sorting-strategy to get the results you want.

HTH,
Bernt




[O] Agenda TODO sorting by date

2012-03-02 Thread James Harkins
Given this:

* Category 1
** TODO First todo in file <2012-03-30 Fri> :Tag:
** TODO Second todo in file <2012-03-29 Thu>:Tag:
* Category 2
** TODO Third todo in file <2012-03-28 Wed> :Tag:
** TODO Fourth todo in file <2012-03-31 Sat>:Tag:

I do C-c a < M Tag  and get:

Headlines with TAGS match: Tag
Press `C-u r' to search again with new search string
  todo_sort:  TODO First todo in file <2012-03-30 Fri> :Tag:
  todo_sort:  TODO Second todo in file <2012-03-29 Thu>:Tag:
  todo_sort:  TODO Third todo in file <2012-03-28 Wed> :Tag:
  todo_sort:  TODO Fourth todo in file <2012-03-31 Sat>:Tag:

I want to configure a custom agenda command so that I get:

Headlines with TAGS match: Tag
Press `C-u r' to search again with new search string
  todo_sort:  TODO Third todo in file <2012-03-28 Wed> :Tag:
  todo_sort:  TODO Second todo in file <2012-03-29 Thu>:Tag:
  todo_sort:  TODO First todo in file <2012-03-30 Fri> :Tag:
  todo_sort:  TODO Fourth todo in file <2012-03-31 Sat>:Tag:

How do I do this?

James


--
James Harkins /// dewdrop world
jamshar...@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



[O] Agenda TODO sorting by date

2012-03-01 Thread James Harkins
I'm still poking around, trying to figure out how to sort my TODO tag search 
the way that I want.

Initially I thought org-agenda-sorting-strategy would do it, but only just 
found the variable's documentation: "Sorting structure for the agenda items of 
a single day."

Since I want to sort the TODO entries *by day* (across multiple days), 
obviously this won't do it.

So I still have the question. Given this (omitting tags):


* Audio Class
** Audio session 03
*** TODO Write next week's assignment <2012-03-04>
* Lessons
** Audio 2010
*** TODO Listen and critique <2012-03-03>
** TODO (something else, not time stamped)


How do I get a tags-search (to-do only) like this?


*** TODO Listen and critique <2012-03-03>
*** TODO Write next week's assignment <2012-03-04>
** TODO (something else, not time stamped)


Currently, I get


*** TODO Write next week's assignment <2012-03-04>
*** TODO Listen and critique <2012-03-03>
*** TODO (something else, not time stamped)


because that's the order in which they appear in the file. So I have to scan 
the whole list to find what's for today, what's for tomorrow etc.

I keep thinking, orgmode can already practically make me a grilled cheese 
sandwich, so there must be a way to do this. Just can't find it.

hjh


--
James Harkins /// dewdrop world
jamshar...@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