From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Poslavsky Subject: org-mac-addressbook.el Date: Sun, 21 Mar 2010 12:38:38 +0100 Message-ID: Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: multipart/mixed; boundary=Apple-Mail-11-954025887 Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NtJUV-0002kZ-Vs for emacs-orgmode@gnu.org; Sun, 21 Mar 2010 07:38:48 -0400 Received: from [140.186.70.92] (port=45545 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtJUU-0002kR-MH for emacs-orgmode@gnu.org; Sun, 21 Mar 2010 07:38:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NtJUT-0008HC-Ib for emacs-orgmode@gnu.org; Sun, 21 Mar 2010 07:38:46 -0400 Received: from ey-out-1920.google.com ([74.125.78.146]:53119) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NtJUT-0008H3-Aj for emacs-orgmode@gnu.org; Sun, 21 Mar 2010 07:38:45 -0400 Received: by ey-out-1920.google.com with SMTP id 4so350885eyg.34 for ; Sun, 21 Mar 2010 04:38:42 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode --Apple-Mail-11-954025887 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hello, playing around with mac integration and org (using org-mac-protocol) I = wrote mac address-book integration. It is slightly based on = org-mac-message. It is the first ever lisp and/or applescript I ever = wrote, so =85 but it works. New hyperlink: = [[address:BC70B043-0144-4AC1-9FFA-9D33F04C8B8A:ABPerson][Name]], which, = when clicked will open the entry in the address book. It works for both = persons as companies. Adding a link to org is done using org-remember (and quicksilver). thanks, Alex Attached: a diff to getItemMetadata from org-mac-protocol, and a new = file called org-mac-addressbook --Apple-Mail-11-954025887 Content-Disposition: attachment; filename=getItemMetadata.applescript.diff Content-Type: application/octet-stream; name="getItemMetadata.applescript.diff" Content-Transfer-Encoding: 7bit diff --git a/orgQSLib/getItemMetadata.applescript b/orgQSLib/getItemMetadata.applescript index 14b201e..6e1f089 100644 --- a/orgQSLib/getItemMetadata.applescript +++ b/orgQSLib/getItemMetadata.applescript @@ -78,7 +78,11 @@ on getItemMetadata(theProtocol, theApp) if (theApp as string) = "Finder" then linkFinder(theProtocol, theApp) else - linkApplication(theProtocol, theApp) + if (theApp as string) = "Address Book" then + linkAddressbook(theProtocol, theApp) + else + linkApplication(theProtocol, theApp) + end if end if end if end if @@ -404,6 +408,29 @@ on linkFinder(theProtocol, theApp) set theLink to theProtocol & escScheme & escPath & "/" & escTitle & "/" & escShortTitle & ":" & escApp end linkFinder + +on linkAddressbook(theProtocol, theApp) + tell application "Address Book" + set theScheme to "address:" + set AllContacts to selection + if number of items in AllContacts = 1 then + set one_contact to item 1 of AllContacts + set theID to id of one_contact + set theName to name of one_contact + else + tell application "System Events" + activate + display dialog "Error: Choose one contact" + end tell + end if + end tell + + set escID to encodeURIComponent(theID) + set escName to encodeURIComponent(theName) + set escScheme to encodeURIComponent(theScheme) + set theLink to theProtocol & escScheme & escID & "/" & escName & ":" & escApp +end linkAddressbook + on linkApplication(theProtocol, theApp) tell application (theApp as string) set theScheme to "file:/" --Apple-Mail-11-954025887 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail-11-954025887 Content-Disposition: attachment; filename=org-mac-addressbook.el Content-Type: application/octet-stream; name="org-mac-addressbook.el" Content-Transfer-Encoding: 7bit ;;;; org-mac-addressbook.el --- Links to Apple Address Book entries from within Org-mode ;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. ;; Author: Alexander Poslavsky ;;;; Commentary: ;; This file implements links from the Apple Address Book entries from within org-mode ;; Org-mode does not load this module by default - if you would actually like ;; this to happen then configure the variable `org-modules'. ;;;; Code: (require 'org) (org-add-link-type "address" 'org-mac-address-open) (defun org-mac-address-open (address-id) "Visit the addresbook-entry with the given address-id" (open-addressbook address-id)) (defun open-addressbook (address-id) "Applescript to open correct address-book entry" (ns-do-applescript (concat "set theID to \"" address-id "\"\n" "tell application \"Address Book\"\n" "set myPerson to first person whose id is theID\n" "set myName to name of first person whose id is theID\n" "set thePeople to selection\n" "end tell\n" "tell application \"System Events\"\n" "activate\n" "try\n" "open location \"addressbook\:\/\/\" \& theID\n" "on error\n" "display dialog \"no matching contact found\"\n" "end try\n" "end tell" ))) (provide 'org-mac-addressbook) --Apple-Mail-11-954025887 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail-11-954025887 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --Apple-Mail-11-954025887--