emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Question about searches (ultimately for agenda)
@ 2009-12-16  1:57 Mueen Nawaz
  2009-12-16  3:26 ` Matt Lundin
  0 siblings, 1 reply; 9+ messages in thread
From: Mueen Nawaz @ 2009-12-16  1:57 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

In the docs (10.3.3 Matching tags and properties), I see ways to do tag 
searches that can also search TODO states.

Can I also search TODO levels? For example, in one file covered by the 
agenda, I use the usual DONE to denote done. In another, which is 
focused on simply stuff that I have borrowed/lent, I have RETURNED as my 
"DONE" state.

I occasionally apply tags to headings with the name of the person 
involved. So let's say that I've put :Jack: on some headings of items 
that have been lent and returned. But I also have :Jack: in my other 
.org files that are not about lending/borrowing.

I want to search for all headlines that have :Jack: in them, but exclude 
anything that is a "DONE" state - so exclude both DONE and RETURNED.

I know I can just do:
Jack-TODO="DONE"-TODO="RETURNED"

But I don't want to keep editing it as I change my DONE states or add 
more DONE states.

Is this possible?

Thanks.

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

* Re: Question about searches (ultimately for agenda)
  2009-12-16  1:57 Question about searches (ultimately for agenda) Mueen Nawaz
@ 2009-12-16  3:26 ` Matt Lundin
  2009-12-16  3:35   ` Mueen Nawaz
  0 siblings, 1 reply; 9+ messages in thread
From: Matt Lundin @ 2009-12-16  3:26 UTC (permalink / raw)
  To: Mueen Nawaz; +Cc: emacs-orgmode

Mueen Nawaz <mueen@nawaz.org> writes:

> In the docs (10.3.3 Matching tags and properties), I see ways to do
> tag searches that can also search TODO states.
>
> Can I also search TODO levels? For example, in one file covered by the
> agenda, I use the usual DONE to denote done. In another, which is
> focused on simply stuff that I have borrowed/lent, I have RETURNED as
> my "DONE" state.
>
> I occasionally apply tags to headings with the name of the person
> involved. So let's say that I've put :Jack: on some headings of items
> that have been lent and returned. But I also have :Jack: in my other
> .org files that are not about lending/borrowing.
>
> I want to search for all headlines that have :Jack: in them, but
> exclude anything that is a "DONE" state - so exclude both DONE and
> RETURNED.
>
> I know I can just do:
> Jack-TODO="DONE"-TODO="RETURNED"

Provided DONE and RETURNED are inactive todos than the following should
suffice:

C-a M Jack [RET]

AFAIK, C-a M returns only active TODOs that match the tag. Thus any
inactive state will be excluded. (There may be a variable that
controls this, but I'm not aware of it.)

Best,
Matt

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

* Re: Question about searches (ultimately for agenda)
  2009-12-16  3:26 ` Matt Lundin
@ 2009-12-16  3:35   ` Mueen Nawaz
  2009-12-16  9:37     ` Carsten Dominik
  2009-12-16 12:02     ` Matt Lundin
  0 siblings, 2 replies; 9+ messages in thread
From: Mueen Nawaz @ 2009-12-16  3:35 UTC (permalink / raw)
  To: emacs-orgmode

On 12/15/09 21:26, Matt Lundin wrote:
> Provided DONE and RETURNED are inactive todos than the following should
> suffice:
>
> C-a M Jack [RET]

	I think you meant C-c a M Jack [RET]

	It actually does filter out inactive TODO's, but I actually wanted to 
do C-c a m Jack [RET]. I don't want to limit the search to headlines 
that have a TODO state. I just want to exclude those that have DONE (or 
anything equivalent to it).

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

* Re: Re: Question about searches (ultimately for agenda)
  2009-12-16  3:35   ` Mueen Nawaz
@ 2009-12-16  9:37     ` Carsten Dominik
  2009-12-17  4:53       ` Mueen Nawaz
  2009-12-16 12:02     ` Matt Lundin
  1 sibling, 1 reply; 9+ messages in thread
From: Carsten Dominik @ 2009-12-16  9:37 UTC (permalink / raw)
  To: Mueen Nawaz; +Cc: emacs-orgmode


On Dec 16, 2009, at 4:35 AM, Mueen Nawaz wrote:

> On 12/15/09 21:26, Matt Lundin wrote:
>> Provided DONE and RETURNED are inactive todos than the following  
>> should
>> suffice:
>>
>> C-a M Jack [RET]
>
> 	I think you meant C-c a M Jack [RET]
>
> 	It actually does filter out inactive TODO's, but I actually wanted  
> to do C-c a m Jack [RET]. I don't want to limit the search to  
> headlines that have a TODO state. I just want to exclude those that  
> have DONE (or anything equivalent to it).

This is what skip conditions are for.  Here is an entry for
org-agenda-custom-commands which does this for the specific
"Jack" example:

("X" "Tags match ignoring done stuff" tags "Jack"
   ((org-agenda-skip-function
     '(and
       (org-entry-is-done-p)
       (outline-next-heading)
       (point)))))

If you want to be prompted for the tags match, leave the match element
empty (empty string).  But do that only after you next upgrade from
the git repo, because there was a bug related to prompting.

Hope this helps

- Carsten

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

* Re: Question about searches (ultimately for agenda)
  2009-12-16  3:35   ` Mueen Nawaz
  2009-12-16  9:37     ` Carsten Dominik
@ 2009-12-16 12:02     ` Matt Lundin
  1 sibling, 0 replies; 9+ messages in thread
From: Matt Lundin @ 2009-12-16 12:02 UTC (permalink / raw)
  To: Mueen Nawaz; +Cc: emacs-orgmode

Mueen Nawaz <mueen@nawaz.org> writes:

> On 12/15/09 21:26, Matt Lundin wrote:
>> Provided DONE and RETURNED are inactive todos than the following should
>> suffice:
>>
>> C-a M Jack [RET]
>
> 	I think you meant C-c a M Jack [RET]

Yes indeed. I'm still practicing typing out the notation for
keybindings. I suppose that C-c a is such a quick maneuver that I
instinctively shorten its notation. :)

> 	It actually does filter out inactive TODO's, but I actually
> wanted to do C-c a m Jack [RET]. I don't want to limit the search to
> headlines that have a TODO state. I just want to exclude those that
> have DONE (or anything equivalent to it).

Ah yes. Now I see that this is indeed what you were requesting in the
original post. I suppose I need to brush up on basic logic as well. :)

There is a shortened tag search syntax for including or excluding TODO
states:

C-c a m [RET] Jack/-DONE-RETURNED

You could assign this a shortcut in using org-agenda-custom-commands
command to avoid having to type it repeatedly. I'm not aware if there is
a shorter way to indicate *all* inactive todo states in such a search.

Best,
Matt

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

* Re: Question about searches (ultimately for agenda)
  2009-12-16  9:37     ` Carsten Dominik
@ 2009-12-17  4:53       ` Mueen Nawaz
  2009-12-17 19:26         ` Carsten Dominik
  0 siblings, 1 reply; 9+ messages in thread
From: Mueen Nawaz @ 2009-12-17  4:53 UTC (permalink / raw)
  To: emacs-orgmode

On 12/16/09 03:37, Carsten Dominik wrote:
> This is what skip conditions are for. Here is an entry for
> org-agenda-custom-commands which does this for the specific
> "Jack" example:
>
> ("X" "Tags match ignoring done stuff" tags "Jack"
> ((org-agenda-skip-function
> '(and
> (org-entry-is-done-p)
> (outline-next-heading)
> (point)))))

	Almost. It worked if I exclude (outline-next-heading). Was there a 
reason you had that?

	Also, I'm pretty weak with Emacs Lisp. What does (point) do? Google's 
no help (obviously).

> If you want to be prompted for the tags match, leave the match element
> empty (empty string). But do that only after you next upgrade from
> the git repo, because there was a bug related to prompting.

	Thanks. I'll wait till the next version, and then add the config in - 
no rush!

Mueen

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

* Re: Re: Question about searches (ultimately for agenda)
  2009-12-17  4:53       ` Mueen Nawaz
@ 2009-12-17 19:26         ` Carsten Dominik
  2009-12-19  4:35           ` Mueen Nawaz
  0 siblings, 1 reply; 9+ messages in thread
From: Carsten Dominik @ 2009-12-17 19:26 UTC (permalink / raw)
  To: Mueen Nawaz; +Cc: emacs-orgmode


On Dec 17, 2009, at 5:53 AM, Mueen Nawaz wrote:

> On 12/16/09 03:37, Carsten Dominik wrote:
>> This is what skip conditions are for. Here is an entry for
>> org-agenda-custom-commands which does this for the specific
>> "Jack" example:
>>
>> ("X" "Tags match ignoring done stuff" tags "Jack"
>> ((org-agenda-skip-function
>> '(and
>> (org-entry-is-done-p)
>> (outline-next-heading)
>> (point)))))
>
> 	Almost. It worked if I exclude (outline-next-heading). Was there a  
> reason you had that?

Yes, so that the search only continues after that entry.  But yes, you
are right, this can fail for the final entry in a file.

Try


'(when (org-entry-is-done) (outline-next-heading) (point))

>
> 	Also, I'm pretty weak with Emacs Lisp. What does (point) do?  
> Google's no help (obviously).

Point returns the buffer position of he cursor, in this case the  
position where the next entry starts.

HTH

- Carsten

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

* Re: Question about searches (ultimately for agenda)
  2009-12-17 19:26         ` Carsten Dominik
@ 2009-12-19  4:35           ` Mueen Nawaz
  2009-12-20 12:51             ` Carsten Dominik
  0 siblings, 1 reply; 9+ messages in thread
From: Mueen Nawaz @ 2009-12-19  4:35 UTC (permalink / raw)
  To: emacs-orgmode

On 12/17/09 13:26, Carsten Dominik wrote:
> Yes, so that the search only continues after that entry. But yes, you
> are right, this can fail for the final entry in a file.
>
> Try
>
> '(when (org-entry-is-done) (outline-next-heading) (point))

	Seems to work.

>> Also, I'm pretty weak with Emacs Lisp. What does (point) do? Google's
>> no help (obviously).
>
> Point returns the buffer position of he cursor, in this case the
> position where the next entry starts.

	OK. I guess I don't understand why we need to know where the point is. 
Is this returning the value of the point in whatever buffer I am when I 
/execute/ the agenda command? Or is this more like the function is 
sweeping the point across all agenda files to find headlines? Or...?

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

* Re: Re: Question about searches (ultimately for agenda)
  2009-12-19  4:35           ` Mueen Nawaz
@ 2009-12-20 12:51             ` Carsten Dominik
  0 siblings, 0 replies; 9+ messages in thread
From: Carsten Dominik @ 2009-12-20 12:51 UTC (permalink / raw)
  To: Mueen Nawaz; +Cc: emacs-orgmode


On Dec 19, 2009, at 5:35 AM, Mueen Nawaz wrote:

> On 12/17/09 13:26, Carsten Dominik wrote:
>> Yes, so that the search only continues after that entry. But yes, you
>> are right, this can fail for the final entry in a file.
>>
>> Try
>>
>> '(when (org-entry-is-done) (outline-next-heading) (point))
>
> 	Seems to work.
>
>>> Also, I'm pretty weak with Emacs Lisp. What does (point) do?  
>>> Google's
>>> no help (obviously).
>>
>> Point returns the buffer position of he cursor, in this case the
>> position where the next entry starts.
>
> 	OK. I guess I don't understand why we need to know where the point  
> is.

The agenda skip function is called to check if an entry should be  
skipped.  At each entry that matches the current query definition  
while sweeping an agenda file, this function will be called to give  
you a final chance to say NO to this entry.  If it returns nil, that  
means, OK, take the entry and put it into the agenda.  If it returns  
something else, that must be the location from where to resume search  
for another match of your query.

For example it can return the location of the end of the current entry  
to make search continue from there.  Or the location of the end of the  
entire subtree end to make search continue from there.  You could also  
return (point-at-eob) to make sure that after skipping this entry, the  
search in this buffer will find nothing more.  You you also make it  
return 1 o start from the beginning of the bugger an in this way end  
up in an infinite loop :-)

Clearer now?

> Is this returning the value of the point in whatever buffer I am  
> when I /execute/ the agenda command? Or is this more like the  
> function is sweeping the point across all agenda files to find  
> headlines? Or...?
>
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

end of thread, other threads:[~2009-12-20 12:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-16  1:57 Question about searches (ultimately for agenda) Mueen Nawaz
2009-12-16  3:26 ` Matt Lundin
2009-12-16  3:35   ` Mueen Nawaz
2009-12-16  9:37     ` Carsten Dominik
2009-12-17  4:53       ` Mueen Nawaz
2009-12-17 19:26         ` Carsten Dominik
2009-12-19  4:35           ` Mueen Nawaz
2009-12-20 12:51             ` Carsten Dominik
2009-12-16 12:02     ` Matt Lundin

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