Automatic detection of the presence of Skim.app
Automatically detect whether the option for Skim.app should be enabled by default or not. Thanks to Ivan Andurs.
This commit is contained in:
parent
feb43669d6
commit
14d45215c3
|
@ -128,7 +128,9 @@ applications and inserting them in org documents"
|
||||||
:group 'org-mac-link-grabber
|
:group 'org-mac-link-grabber
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
(defcustom org-mac-grab-Skim-app-p t
|
(defcustom org-mac-grab-Skim-app-p
|
||||||
|
(< 0 (length (shell-command-to-string
|
||||||
|
"mdfind kMDItemCFBundleIdentifier == 'net.sourceforge.skim-app.skim'")))
|
||||||
"Enable menu option [S]kim to grab page links from Skim.app"
|
"Enable menu option [S]kim to grab page links from Skim.app"
|
||||||
:tag "Grab Skim.app page links"
|
:tag "Grab Skim.app page links"
|
||||||
:group 'org-mac-link-grabber
|
:group 'org-mac-link-grabber
|
||||||
|
@ -472,7 +474,7 @@ applications and inserting them in org documents"
|
||||||
;;
|
;;
|
||||||
;; Handle links from Skim.app
|
;; Handle links from Skim.app
|
||||||
;;
|
;;
|
||||||
;; A rewriting of some code originally by Christopher Suckling from org-mac-protocol
|
;; Original code & idea by Christopher Suckling (org-mac-protocol)
|
||||||
|
|
||||||
(org-add-link-type "skim" 'org-mac-skim-open)
|
(org-add-link-type "skim" 'org-mac-skim-open)
|
||||||
|
|
||||||
|
@ -486,7 +488,7 @@ applications and inserting them in org documents"
|
||||||
"tell application \"Skim\"\n"
|
"tell application \"Skim\"\n"
|
||||||
"activate\n"
|
"activate\n"
|
||||||
"set theDoc to \"" document "\"\n"
|
"set theDoc to \"" document "\"\n"
|
||||||
"set thePage to " page "\n"
|
"set thePage to " page "\n"
|
||||||
"open theDoc\n"
|
"open theDoc\n"
|
||||||
"go document 1 to page thePage of document 1\n"
|
"go document 1 to page thePage of document 1\n"
|
||||||
"end tell"))))
|
"end tell"))))
|
||||||
|
@ -503,7 +505,7 @@ applications and inserting them in org documents"
|
||||||
"set theSelection to selection of theDoc\n"
|
"set theSelection to selection of theDoc\n"
|
||||||
"set theContent to contents of (get text for theSelection)\n"
|
"set theContent to contents of (get text for theSelection)\n"
|
||||||
"if theContent is missing value then\n"
|
"if theContent is missing value then\n"
|
||||||
"set theContent to theTitle & \", p. \" & thePage\n"
|
" set theContent to theTitle & \", p. \" & thePage\n"
|
||||||
"end if\n"
|
"end if\n"
|
||||||
"set theLink to \"skim://\" & thePath & \"::\" & thePage & "
|
"set theLink to \"skim://\" & thePath & \"::\" & thePage & "
|
||||||
"\"::split::\" & theContent\n"
|
"\"::split::\" & theContent\n"
|
||||||
|
@ -513,13 +515,13 @@ applications and inserting them in org documents"
|
||||||
(defun org-mac-skim-get-page ()
|
(defun org-mac-skim-get-page ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(message "Applescript: Getting Skim page link...")
|
(message "Applescript: Getting Skim page link...")
|
||||||
(let* ((url-and-title (as-get-skim-page-link))
|
(let* ((link-and-descr (as-get-skim-page-link))
|
||||||
(split-link (split-string url-and-title "::split::"))
|
(split-link (split-string link-and-descr "::split::"))
|
||||||
(URL (car split-link))
|
(link (car split-link))
|
||||||
(description (cadr split-link))
|
(description (cadr split-link))
|
||||||
(org-link))
|
(org-link))
|
||||||
(when (not (string= URL ""))
|
(when (not (string= link ""))
|
||||||
(setq org-link (org-make-link-string URL description)))
|
(setq org-link (org-make-link-string link description)))
|
||||||
(kill-new org-link)
|
(kill-new org-link)
|
||||||
org-link))
|
org-link))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue