From mboxrd@z Thu Jan  1 00:00:00 1970
From: Mike McLean <mike.mclean@pobox.com>
Subject: [PATCH] Org Mac Outlook opens messages via AppleScript
Date: Sun, 13 Oct 2013 09:04:59 -0400
Message-ID: <20131013141600.BEE015E0AF63@mac-mike-2013.mclean>
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from eggs.gnu.org ([2001:4830:134:3::10]:37396)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mike.mclean@pobox.com>) id 1VVMSt-0007ux-0M
	for emacs-orgmode@gnu.org; Sun, 13 Oct 2013 10:16:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mike.mclean@pobox.com>) id 1VVMSj-0007Sc-AV
	for emacs-orgmode@gnu.org; Sun, 13 Oct 2013 10:16:14 -0400
Received: from b-pb-sasl-quonix.pobox.com ([208.72.237.35]:62250
	helo=smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mike.mclean@pobox.com>) id 1VVMSj-0007S9-6K
	for emacs-orgmode@gnu.org; Sun, 13 Oct 2013 10:16:05 -0400
Received: from smtp.pobox.com (unknown [127.0.0.1])
	by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 011BB48B05
	for <emacs-orgmode@gnu.org>; Sun, 13 Oct 2013 14:16:02 +0000 (UTC)
Received: from b-pb-sasl-quonix.pobox.com (unknown [127.0.0.1])
	by b-sasl-quonix.pobox.com (Postfix) with ESMTP id E84DF48B04
	for <emacs-orgmode@gnu.org>; Sun, 13 Oct 2013 14:16:01 +0000 (UTC)
Received: from mac-mike-2013.mclean (unknown [67.190.221.110])
	by b-sasl-quonix.pobox.com (Postfix) with ESMTPA id 5D33348B01
	for <emacs-orgmode@gnu.org>; Sun, 13 Oct 2013 14:16:01 +0000 (UTC)
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=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

Previously ~org-mac-outlook-message-open~ used the Mac OS X Spotlight
index via ~mdfind~ to open messages via shell commands. This patch
changes the open to an AppleScript method to resolve an issue reported
by Manish Sharma.
---
 contrib/lisp/org-mac-link.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 2ff6711..ebcff75 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -593,13 +593,13 @@ applications and inserting them in org documents"
 (org-add-link-type "mac-outlook" 'org-mac-outlook-message-open)
 
 (defun org-mac-outlook-message-open (msgid)
-  "Open a message in outlook"
-  (let* ((record-id-string (format "mdfind com_microsoft_outlook_recordID==%s" msgid))
-	(found-message (replace-regexp-in-string "\n$" ""
-              (shell-command-to-string record-id-string))))
-    (if (string= found-message "")
-      (message "org-mac-link: error could not find Outlook message %s" 	(substring-no-properties msgid))
-      (shell-command (format "open \"`mdfind com_microsoft_outlook_recordID==%s`\"" msgid)))))
+  "Open a message in Outlook"
+  (do-applescript
+   (concat
+    "tell application \"Microsoft Outlook\"\n"
+     (format "open message id %s\n" (substring-no-properties msgid))
+     "activate\n"
+     "end tell")))
 
 (defun org-as-get-selected-outlook-mail ()
   "AppleScript to create links to selected messages in Microsoft Outlook.app."
-- 
1.8.3.4