* [PATCH] org-contacts: Fix org-contacts-gnus-article-from-goto
@ 2013-05-04 14:09 Rodney Lorrimar
2013-05-04 16:49 ` Carsten Dominik
0 siblings, 1 reply; 2+ messages in thread
From: Rodney Lorrimar @ 2013-05-04 14:09 UTC (permalink / raw)
To: emacs-orgmode
* 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.
---
contrib/lisp/org-contacts.el | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
index c72e6c0..c84f1f2 100644
--- a/contrib/lisp/org-contacts.el
+++ b/contrib/lisp/org-contacts.el
@@ -233,10 +233,15 @@ A regexp matching strings of whitespace, `,' and `;'.")
(progress-reporter-done progress-reporter)))
org-contacts-db))
-(defun org-contacts-filter (&optional name-match tags-match)
- "Search for a contact matching NAME-MATCH and TAGS-MATCH.
-If both match values are nil, return all contacts."
+(defun org-contacts-filter (&optional name-match tags-match prop-match)
+ "Search for a contact matching any of NAME-MATCH, TAGS-MATCH, PROP-MATCH.
+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)
+ (null prop-match)
(null tags-match))
(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
(org-string-match-p name-match
(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
(org-find-if (lambda (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)))
(cadar (or (org-contacts-filter
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
(org-contacts-filter
(concat "^" name "$")))))))
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] org-contacts: Fix org-contacts-gnus-article-from-goto
2013-05-04 14:09 [PATCH] org-contacts: Fix org-contacts-gnus-article-from-goto Rodney Lorrimar
@ 2013-05-04 16:49 ` Carsten Dominik
0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2013-05-04 16:49 UTC (permalink / raw)
To: Rodney Lorrimar; +Cc: emacs-orgmode
Applied, thanks.
- Carsten
On 4.5.2013, at 16:09, Rodney Lorrimar <rodney@rodney.id.au> wrote:
> * 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.
> ---
> contrib/lisp/org-contacts.el | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el
> index c72e6c0..c84f1f2 100644
> --- a/contrib/lisp/org-contacts.el
> +++ b/contrib/lisp/org-contacts.el
> @@ -233,10 +233,15 @@ A regexp matching strings of whitespace, `,' and `;'.")
> (progress-reporter-done progress-reporter)))
> org-contacts-db))
>
> -(defun org-contacts-filter (&optional name-match tags-match)
> - "Search for a contact matching NAME-MATCH and TAGS-MATCH.
> -If both match values are nil, return all contacts."
> +(defun org-contacts-filter (&optional name-match tags-match prop-match)
> + "Search for a contact matching any of NAME-MATCH, TAGS-MATCH, PROP-MATCH.
> +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)
> + (null prop-match)
> (null tags-match))
> (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
> (org-string-match-p name-match
> (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
> (org-find-if (lambda (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)))
> (cadar (or (org-contacts-filter
> 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
> (org-contacts-filter
> (concat "^" name "$")))))))
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-04 16:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-04 14:09 [PATCH] org-contacts: Fix org-contacts-gnus-article-from-goto Rodney Lorrimar
2013-05-04 16:49 ` Carsten Dominik
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.