diff options
author | Grégoire Jadi <gregoire.jadi@gmail.com> | 2014-07-13 19:33:34 +0900 |
---|---|---|
committer | Grégoire Jadi <gregoire.jadi@gmail.com> | 2014-07-13 19:34:27 +0900 |
commit | 9cf3c4e9712aba63be36eac7193e4ac85f491f8b (patch) | |
tree | d7413384c1f3d948d51ed1c0916f0e9be1f63688 | |
parent | a11ce0b4562d12cd649de20c74ee92e27d0b8d44 (diff) | |
download | org-mode-9cf3c4e9712aba63be36eac7193e4ac85f491f8b.tar.gz |
contrib/lisp/org-contacts.el: Fix a bug when contacts don't have an email address
* contrib/lisp/org-contacts.el (org-contacts-complete-tags-props,
org-contacts-complete-group): Fix a bug when contacts don't have an
email address.
-rw-r--r-- | contrib/lisp/org-contacts.el | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el index 9ddf28d..583da4a 100644 --- a/contrib/lisp/org-contacts.el +++ b/contrib/lisp/org-contacts.el @@ -516,11 +516,12 @@ A group FOO is composed of contacts with the tag FOO." ;; returned by `org-contacts-filter'. for contact-name = (car contact) ;; Grab the first email of the contact - for email = (org-contacts-strip-link (car (org-contacts-split-property - (or - (cdr (assoc-string org-contacts-email-property - (caddr contact))) - "")))) + for email = (org-contacts-strip-link + (or (car (org-contacts-split-property + (or + (cdr (assoc-string org-contacts-email-property + (caddr contact))) + ""))) "")) ;; If the user has an email address, append USER <EMAIL>. if email collect (org-contacts-format-email contact-name email)) ", "))) @@ -528,7 +529,7 @@ A group FOO is composed of contacts with the tag FOO." (completion-table-case-fold completion-list (not org-contacts-completion-ignore-case)))))))) -(defun org-contacts-complete-tags-props (start end matcher) +(defun org-contacts-complete-tags-props (start end string) "Insert emails that match the tags expression. For example: FOO-BAR will match entries tagged with FOO but not @@ -538,25 +539,28 @@ See (org) Matching tags and properties for a complete description." (let* ((completion-ignore-case org-contacts-completion-ignore-case) (completion-p (org-string-match-p - (concat "^" org-contacts-tags-props-prefix) string))) + (concat "^" org-contacts-tags-props-prefix) string))) (when completion-p (let ((result (mapconcat 'identity (loop for contact in (org-contacts-db) for contact-name = (car contact) - for email = (org-contacts-strip-link (car (org-contacts-split-property + for email = (org-contacts-strip-link (or (car (org-contacts-split-property (or (cdr (assoc-string org-contacts-email-property (caddr contact))) - "")))) + ""))) "")) for tags = (cdr (assoc "TAGS" (nth 2 contact))) for tags-list = (if tags (split-string (substring (cdr (assoc "TAGS" (nth 2 contact))) 1 -1) ":") '()) - if (let ((todo-only nil)) - (eval (cdr (org-make-tags-matcher matcher)))) - + for marker = (second contact) + if (with-current-buffer (marker-buffer marker) + (save-excursion + (goto-char marker) + (let (todo-only) + (eval (cdr (org-make-tags-matcher (subseq string 1))))))) collect (org-contacts-format-email contact-name email)) ","))) (when (not (string= "" result)) |