From cb943216ae4d4a5ff2ab0295d0d026b6cbdfb4ea Mon Sep 17 00:00:00 2001
From: Daniil Frumin <difrumin@gmail.com>
Date: Tue, 14 May 2013 10:13:50 +0400
Subject: [PATCH 4/4] Add the ability to highlight the selected text in
 Skim.app

Make a 'highlight note' upon grabbing a link from Skim.app if the
option 'org-mac-Skim-highlight-selection-p' is t.
---
 contrib/lisp/org-mac-link-grabber.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/contrib/lisp/org-mac-link-grabber.el b/contrib/lisp/org-mac-link-grabber.el
index cb92b44..59f4820 100644
--- a/contrib/lisp/org-mac-link-grabber.el
+++ b/contrib/lisp/org-mac-link-grabber.el
@@ -136,6 +136,12 @@ applications and inserting them in org documents"
   :group 'org-mac-link-grabber
   :type 'boolean)
 
+(defcustom org-mac-Skim-highlight-selection-p nil
+  "Highlight (using notes) the selection (if present) when grabbing the a link from Skim.app"
+  :tag "Highlight selection in Skim.app"
+  :group 'org-mac-link-grabber
+  :type 'boolean)
+
 
 (defun omlg-grab-link ()
   "Prompt the user for an application to grab a link from, then go grab the link, and insert it at point"
@@ -506,6 +512,13 @@ applications and inserting them in org documents"
        "set theContent to contents of (get text for theSelection)\n"
        "if theContent is missing value then\n"
        "    set theContent to theTitle & \", p. \" & thePage\n"
+       (when org-mac-Skim-highlight-selection-p
+	 (concat
+	  "else\n"
+          "    tell theDoc\n"
+          "        set theNote to make note with properties {type:highlight note, selection:theSelection}\n"
+          "         set text of theNote to (get text for theSelection)\n"
+          "    end tell\n"))
        "end if\n"
        "set theLink to \"skim://\" & thePath & \"::\" & thePage & "
        "\"::split::\" & theContent\n"
-- 
1.7.12.4 (Apple Git-37)

