org-contacts: Fix org-contacts-gnus-article-from-goto

* contrib/lisp/org-contacts.el (org-contacts-filter): Add a PROP-MATCH
argument.
(org-contacts-gnus-article-from-get-marker): Search for email as a
property not a tag.

`org-contacts-gnus-article-from-get-marker' seems to assume that the
contact properties exist within the contact's tags as colon-separated
KEY={VALUE} entries.  This isn't the case for me, using org-mode from
git master.

This commit adds a PROP-MATCH argument to `org-contacts-filter' so
that `org-contacts-gnus-article-from-get-marker` can filter by the
EMAIL property.
This commit is contained in:
Rodney Lorrimar 2013-05-04 22:09:47 +08:00 committed by Carsten Dominik
parent beb76bf435
commit 43d6571612

View file

@ -233,10 +233,15 @@ A regexp matching strings of whitespace, `,' and `;'.")
(progress-reporter-done progress-reporter))) (progress-reporter-done progress-reporter)))
org-contacts-db)) org-contacts-db))
(defun org-contacts-filter (&optional name-match tags-match) (defun org-contacts-filter (&optional name-match tags-match prop-match)
"Search for a contact matching NAME-MATCH and TAGS-MATCH. "Search for a contact matching any of NAME-MATCH, TAGS-MATCH, PROP-MATCH.
If both match values are nil, return all contacts." If all match values are nil, return all contacts.
The optional PROP-MATCH argument is a single (PROP . VALUE) cons
cell corresponding to the contact properties.
"
(if (and (null name-match) (if (and (null name-match)
(null prop-match)
(null tags-match)) (null tags-match))
(org-contacts-db) (org-contacts-db)
(loop for contact in (org-contacts-db) (loop for contact in (org-contacts-db)
@ -244,6 +249,11 @@ If both match values are nil, return all contacts."
(and name-match (and name-match
(org-string-match-p name-match (org-string-match-p name-match
(first contact))) (first contact)))
(and prop-match
(org-find-if (lambda (prop)
(and (string= (car prop-match) (car prop))
(org-string-match-p (cdr prop-match) (cdr prop))))
(caddr contact)))
(and tags-match (and tags-match
(org-find-if (lambda (tag) (org-find-if (lambda (tag)
(org-string-match-p tags-match tag)) (org-string-match-p tags-match tag))
@ -523,7 +533,8 @@ A group FOO is composed of contacts with the tag FOO."
(email (cadr address))) (email (cadr address)))
(cadar (or (org-contacts-filter (cadar (or (org-contacts-filter
nil nil
(concat org-contacts-email-property "={\\b" (regexp-quote email) "\\b}")) nil
(cons org-contacts-email-property (concat "\\b" (regexp-quote email) "\\b")))
(when name (when name
(org-contacts-filter (org-contacts-filter
(concat "^" name "$"))))))) (concat "^" name "$")))))))