From a5e8c7f4463de7c3d25ca2569cba40e60604b0c7 Mon Sep 17 00:00:00 2001
From: Mike McLean <mike.mclean@pobox.com>
Date: Mon, 14 Dec 2015 11:09:03 -0500
Subject: [PATCH] org-mac-link.el: Make path to Microsoft Outlook customizable

* org-mac-link.el (org-mac-outlook-path): New Custom String to hold the file system path to Microsoft Outlook
(org-mac-outlook-message-open, org-as-get-selected-outlook-mail): Use
 the new custom string instead of hard-coding the path to Outlook
---
 contrib/lisp/org-mac-link.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 01556f7..25f47e1 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -21,7 +21,11 @@
 ;; Version: 1.3
 ;; Author: Alan Schmitt <alan.schmitt@polytechnique.org>
 ;; Consistently use `org-mac-paste-applescript-links'
-;; 
+;;
+;; Version 1.4
+;; Author: Mike McLean <mike.mclean@pobox.com>
+;; Make the path to Microsoft Outlook a `defcustom'
+;;
 ;; This file is not part of GNU Emacs.
 ;;
 ;; This program is free software; you can redistribute it and/or modify
@@ -113,6 +117,12 @@
   :group 'org-mac-link
   :type 'boolean)
 
+(defcustom org-mac-outlook-path "/Applications/Microsoft Outlook.app"
+  "The path to the installed copy of Microsoft Outlook. Do not escape spaces as this string will quoted in the AppleScript call."
+  :tag "Path to Microsoft Outlook"
+  :group 'org-mac-link
+  :type 'string)
+
 (defcustom org-mac-grab-devonthink-app-p t
   "Add menu option [d]EVONthink to grab links from DEVONthink Pro Office.app."
   :tag "Grab DEVONthink Pro Office.app links"
@@ -610,7 +620,7 @@ The links are of the form <link>::split::<name>."
   "Open a message in Outlook"
   (do-applescript
    (concat
-    "tell application \"/Applications/Microsoft Office 2011/Microsoft Outlook.app\"\n"
+    "tell application \"" org-mac-outlook-path "\"\n"
     (format "open message id %s\n" (substring-no-properties msgid))
     "activate\n"
     "end tell")))
@@ -619,7 +629,7 @@ The links are of the form <link>::split::<name>."
   "AppleScript to create links to selected messages in Microsoft Outlook.app."
   (do-applescript
    (concat
-    "tell application \"/Applications/Microsoft Office 2011/Microsoft Outlook.app\"\n"
+    "tell application \"" org-mac-outlook-path "\"\n"
     "set msgCount to count current messages\n"
     "if (msgCount < 1) then\n"
     "return\n"
-- 
2.6.4

