From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: org-contacts email completion by tags Date: Thu, 5 Jun 2014 12:54:19 -0400 Message-ID: References: <87oay8ez6c.fsf@tanger.home> <87bnu7fucv.fsf@tanger.home> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8ff25378987dc604fb19981b Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsavt-0004ah-Jr for emacs-orgmode@gnu.org; Thu, 05 Jun 2014 12:54:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wsavl-0006CO-Fl for emacs-orgmode@gnu.org; Thu, 05 Jun 2014 12:54:29 -0400 Received: from mail-pd0-x22e.google.com ([2607:f8b0:400e:c02::22e]:52606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsavl-0006Bk-4m for emacs-orgmode@gnu.org; Thu, 05 Jun 2014 12:54:21 -0400 Received: by mail-pd0-f174.google.com with SMTP id r10so1330638pdi.5 for ; Thu, 05 Jun 2014 09:54:20 -0700 (PDT) In-Reply-To: <87bnu7fucv.fsf@tanger.home> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Daimrod Cc: "emacs-orgmode@gnu.org" --e89a8ff25378987dc604fb19981b Content-Type: text/plain; charset=UTF-8 On Thu, Jun 5, 2014 at 7:50 AM, Daimrod wrote: > org-contacts-complete-group Here is a better function I think. It uses the builtin org-contacts database: (defun insert-emails-from-tags (tag-expression) "insert emails from org-contacts that match the tags expression. For example: group-phd will match entries tagged with group but not with phd." (interactive "sTags: ") (insert (mapconcat 'identity (loop for contact in (org-contacts-filter) for contact-name = (car contact) for email = (org-contacts-strip-link (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 tag-expression)))) collect (org-contacts-format-email contact-name email)) ","))) John ----------------------------------- John Kitchin Associate Professor Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu --e89a8ff25378987dc604fb19981b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: base64 PGRpdiBkaXI9Imx0ciI+PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxicj48ZGl2IGNsYXNzPSJn bWFpbF9xdW90ZSI+T24gVGh1LCBKdW4gNSwgMjAxNCBhdCA3OjUwIEFNLCBEYWltcm9kIDxzcGFu IGRpcj0ibHRyIj4mbHQ7PGEgaHJlZj0ibWFpbHRvOmRhaW1yb2RAZ21haWwuY29tIiB0YXJnZXQ9 Il9ibGFuayI+ZGFpbXJvZEBnbWFpbC5jb208L2E+Jmd0Ozwvc3Bhbj4gd3JvdGU6PGJyPg0KPGJs b2NrcXVvdGUgY2xhc3M9ImdtYWlsX3F1b3RlIiBzdHlsZT0ibWFyZ2luOjBweCAwcHggMHB4IDAu OGV4O2JvcmRlci1sZWZ0OjFweCBzb2xpZCByZ2IoMjA0LDIwNCwyMDQpO3BhZGRpbmctbGVmdDox ZXgiPm9yZy1jb250YWN0cy1jb21wbGV0ZS1ncm91cDwvYmxvY2txdW90ZT48L2Rpdj48YnI+PC9k aXY+PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPkhlcmUgaXMgYSBiZXR0ZXIgZnVuY3Rpb24gSSB0 aGluay4gSXQgdXNlcyB0aGUgYnVpbHRpbiBvcmctY29udGFjdHMgZGF0YWJhc2U6PGJyPg0KPGJy PihkZWZ1biBpbnNlcnQtZW1haW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