emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to do Properties search by define an agenda command
@ 2010-11-10  7:59 Chao LU
  2010-11-10 18:30 ` David Maus
  2010-11-12  1:39 ` Matt Lundin
  0 siblings, 2 replies; 6+ messages in thread
From: Chao LU @ 2010-11-10  7:59 UTC (permalink / raw)
  To: emacs-orgmode


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

Dear all,

I'm trying to figure out how  to do Properties search by define an agenda
command.

Here is my item in org file:

*** Franz Schwabl / Quantum Mechanics
    :PROPERTIES:
    :TITLE: Quantum Mechanics
    :AUTHOR: Franz Schwabl
    :CATEGORY: Quantum Mechanics
    :TAGS: Quantum Mechanics, Group Theory
    :KEYWORD: Quantum Mechanics, Perturbation, Second Quantization
    :LOCATION: iTune
    :END:

And I want to define a agenda command to search this item out. I've tried
this one, but did not work:
     ("19" "TEST" occur-tree "Title="Quantum Mechanics"")
     ("19" "TEST" tags "Title="Quantum Mechanics"")

So is there anyone knows how to do this correctly?

Thanks,

Chao

[-- Attachment #1.2: Type: text/html, Size: 872 bytes --]

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

_______________________________________________
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

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

* Re: How to do Properties search by define an agenda command
  2010-11-10  7:59 How to do Properties search by define an agenda command Chao LU
@ 2010-11-10 18:30 ` David Maus
  2010-11-12  1:51   ` Matt Lundin
  2010-11-12  1:39 ` Matt Lundin
  1 sibling, 1 reply; 6+ messages in thread
From: David Maus @ 2010-11-10 18:30 UTC (permalink / raw)
  To: Chao LU; +Cc: emacs-orgmode


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

At Wed, 10 Nov 2010 02:59:58 -0500,
Chao LU wrote:
> I'm trying to figure out how  to do Properties search by define an agenda
> command.
>
> Here is my item in org file:
>
> *** Franz Schwabl / Quantum Mechanics
>     :PROPERTIES:
>     :TITLE: Quantum Mechanics
>     :AUTHOR: Franz Schwabl
>     :CATEGORY: Quantum Mechanics
>     :TAGS: Quantum Mechanics, Group Theory
>     :KEYWORD: Quantum Mechanics, Perturbation, Second Quantization
>     :LOCATION: iTune
>     :END:

IIRC the space character of a property value must be escaped (%20)
because Org uses the plain space character to separate multiple values
in a property.  So the drawer should look like:

    :PROPERTIES:
    :TITLE: Quantum%20Mechanics
    :AUTHOR: Franz%20Schwabl
    :CATEGORY: Quantum%20Mechanics
    :TAGS: Quantum%20Mechanics Group%20Theory
    :KEYWORD: Quantum%20Mechanics Perturbation Second%20Quantization
    :LOCATION: iTune
    :END:

But now, sadly, that's all we've got.  The search engine can only
search for equal strings (e.g. TITLE="Quantum%20Mechanics") or regular
expression and it does not handle multivalue properties.

Looks like to use the intended functionality someone has to patch Org
mode's tag search to handle multivalue properties.

Best,
  -- David


--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

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

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

_______________________________________________
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

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

* Re: How to do Properties search by define an agenda command
  2010-11-10  7:59 How to do Properties search by define an agenda command Chao LU
  2010-11-10 18:30 ` David Maus
@ 2010-11-12  1:39 ` Matt Lundin
  1 sibling, 0 replies; 6+ messages in thread
From: Matt Lundin @ 2010-11-12  1:39 UTC (permalink / raw)
  To: Chao LU; +Cc: emacs-orgmode

Chao LU <loochao@gmail.com> writes:

> Dear all,
>
> I'm trying to figure out how  to do Properties search by define an
> agenda command.
>
> Here is my item in org file:
>
> *** Franz Schwabl / Quantum Mechanics
>     :PROPERTIES:
>     :TITLE: Quantum Mechanics
>     :AUTHOR: Franz Schwabl
>     :CATEGORY: Quantum Mechanics
>     :TAGS: Quantum Mechanics, Group Theory
>     :KEYWORD: Quantum Mechanics, Perturbation, Second Quantization
>     :LOCATION: iTune
>     :END:
>
> And I want to define a agenda command to search this item out. I've
> tried this one, but did not work:
>      ("19" "TEST" occur-tree "Title="Quantum Mechanics"")
>      ("19" "TEST" tags "Title="Quantum Mechanics"")
>
> So is there anyone knows how to do this correctly?

Two things: 

1. You need to escape the inner quote marks in the custom command.

2. AFAICT Properties are case sensitive. Your drawer includes a "TITLE"
   property but your custom command searches for "Title".

This custom command worked for me:

(setq org-agenda-custom-commands 
      '(("x" "TEST" tags "TITLE=\"Quantum Mechanics\"")))

You could also just type the following:

C-a m TITLE="Quantum Mechanics"

Note: you can also use regexps in property searches. E.g.,

C-a m TITLE={quantum.*mechanics}

Best,
Matt

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

* Re: How to do Properties search by define an agenda command
  2010-11-10 18:30 ` David Maus
@ 2010-11-12  1:51   ` Matt Lundin
  2010-11-13  6:09     ` David Maus
  0 siblings, 1 reply; 6+ messages in thread
From: Matt Lundin @ 2010-11-12  1:51 UTC (permalink / raw)
  To: David Maus; +Cc: Chao LU, emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

> At Wed, 10 Nov 2010 02:59:58 -0500,
> Chao LU wrote:
>> I'm trying to figure out how  to do Properties search by define an agenda
>> command.
>>
>> Here is my item in org file:
>>
>> *** Franz Schwabl / Quantum Mechanics
>>     :PROPERTIES:
>>     :TITLE: Quantum Mechanics
>>     :AUTHOR: Franz Schwabl
>>     :CATEGORY: Quantum Mechanics
>>     :TAGS: Quantum Mechanics, Group Theory
>>     :KEYWORD: Quantum Mechanics, Perturbation, Second Quantization
>>     :LOCATION: iTune
>>     :END:
>
> IIRC the space character of a property value must be escaped (%20)
> because Org uses the plain space character to separate multiple values
> in a property.  So the drawer should look like:
>
>     :PROPERTIES:
>     :TITLE: Quantum%20Mechanics
>     :AUTHOR: Franz%20Schwabl
>     :CATEGORY: Quantum%20Mechanics
>     :TAGS: Quantum%20Mechanics Group%20Theory
>     :KEYWORD: Quantum%20Mechanics Perturbation Second%20Quantization
>     :LOCATION: iTune
>     :END:
>
> But now, sadly, that's all we've got.  The search engine can only
> search for equal strings (e.g. TITLE="Quantum%20Mechanics") or regular
> expression and it does not handle multivalue properties.

I don't believe this is the case. The following search works fine for me
with the OP's properties drawer:

C-c a m TITLE="Quantum Mechanics"

> Looks like to use the intended functionality someone has to patch Org
> mode's tag search to handle multivalue properties.

I don't believe the space in property values is meant to indicate
multiple values (i.e., in the same way that ":" separates tags). Here's
an example from the manual:

--8<---------------cut here---------------start------------->8---
     * CD collection
     ** Classic
     *** Goldberg Variations
         :PROPERTIES:
         :Title:     Goldberg Variations
         :Composer:  J.S. Bach
         :Artist:    Glen Gould
         :Publisher: Deutsche Grammophon
         :NDisks:    1
         :END:
--8<---------------cut here---------------end--------------->8---

That said, one can create ad hoc multivalue properties by using regexps
in property searches.

Best,
Matt

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

* Re: How to do Properties search by define an agenda command
  2010-11-12  1:51   ` Matt Lundin
@ 2010-11-13  6:09     ` David Maus
  2010-11-13 15:31       ` Matt Lundin
  0 siblings, 1 reply; 6+ messages in thread
From: David Maus @ 2010-11-13  6:09 UTC (permalink / raw)
  To: Matt Lundin; +Cc: David Maus, emacs-orgmode, Chao LU


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

At Thu, 11 Nov 2010 20:51:58 -0500,
Matt Lundin wrote:
> > Looks like to use the intended functionality someone has to patch Org
> > mode's tag search to handle multivalue properties.
>
> I don't believe the space in property values is meant to indicate
> multiple values (i.e., in the same way that ":" separates tags). Here's
> an example from the manual:

This is a misunderstanding: Yes, you can use space characters in
single value properties and use regexps to simulate multivalue
properties.

But you can't use Org's multivalue properties (C-h f
org-entry-put-multivalued-property RET).

Looks like an inconsistency or a glitch: Org supports putting multiple
values in a property but has no reserved separator for multiple
values.  So there is no way for a function recognize multivalue
properties -- what makes it hard to perform a search for properties
with multiple values w/o having the user enter a regular expression.

Best,
  -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

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

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

_______________________________________________
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

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

* Re: How to do Properties search by define an agenda command
  2010-11-13  6:09     ` David Maus
@ 2010-11-13 15:31       ` Matt Lundin
  0 siblings, 0 replies; 6+ messages in thread
From: Matt Lundin @ 2010-11-13 15:31 UTC (permalink / raw)
  To: David Maus; +Cc: Chao LU, emacs-orgmode

David Maus <dmaus@ictsoc.de> writes:

> At Thu, 11 Nov 2010 20:51:58 -0500,
> Matt Lundin wrote:
>> > Looks like to use the intended functionality someone has to patch Org
>> > mode's tag search to handle multivalue properties.

AFAICT, the OP was not inquiring about a multivalue search, but rather
simply asking how to match an entire property value string (i.e., the
title of a book). The problems was caused not by unescaped spaces in
property values, but rather by how the custom agenda search was
constructed (e.g., incorrect property key, unescaped quote marks, etc.).

>> I don't believe the space in property values is meant to indicate
>> multiple values (i.e., in the same way that ":" separates tags). Here's
>> an example from the manual:
>
> This is a misunderstanding: Yes, you can use space characters in
> single value properties and use regexps to simulate multivalue
> properties.
>
> But you can't use Org's multivalue properties (C-h f
> org-entry-put-multivalued-property RET).

Good to know. I wasn't aware of multivalued properties. 

I think my comment still stands: currently, for normal tags/property
searches, single spaces are not intended to indicate multiple values.
The function org-tags-view invokes only the single value property
mechanism (i.e., org-cached-entry-get).

AFAICT, multivalued properties were introduced to accommodate org-attach
but they have not (yet) been used elsewhere in Org-mode. See the
following commit:

--8<---------------cut here---------------start------------->8---
commit d043e31182595983df3d191e80ca941ee171c400
Author: Carsten Dominik <carsten.dominik@gmail.com>
Date:   Wed Oct 1 09:25:18 2008 +0200

    Integrate John Wiegley's org-attach.el.
--8<---------------cut here---------------end--------------->8---

> Looks like an inconsistency or a glitch: Org supports putting multiple
> values in a property but has no reserved separator for multiple
> values.  So there is no way for a function recognize multivalue
> properties -- what makes it hard to perform a search for properties
> with multiple values w/o having the user enter a regular expression.

Currently, the only way to extract multivalue properties is to use the
API functions:

(info "(org) Using the property API")

I believe single value properties should be the default behavior for
searches (that is how the manual presents properties). I would certainly
*not* want to have to escape spaces in property drawers when, say,
entering AUTHOR and TITLE property values.

Currently, the search logic of is relatively straightforward:

 1. to force an exact property match, use TITLE="Quantum Mechanics"
 2. to allow partial matches, use a regexp: TITLE={Quantum}

Perhaps a patch could introduce an user option to use the multivalued
API in property searches. This could be a nice option for custom
commands. But I would recommend that the single value remain the
default.

Best,
Matt

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

end of thread, other threads:[~2010-11-13 15:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-10  7:59 How to do Properties search by define an agenda command Chao LU
2010-11-10 18:30 ` David Maus
2010-11-12  1:51   ` Matt Lundin
2010-11-13  6:09     ` David Maus
2010-11-13 15:31       ` Matt Lundin
2010-11-12  1:39 ` 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).