From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike McLean Subject: [PATCH] Add DEVONthink Pro to Org Mac Link Date: Sat, 14 Jun 2014 00:32:06 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e01681cd40190a304fbc44892 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvfdu-0006lP-G3 for emacs-orgmode@gnu.org; Sat, 14 Jun 2014 00:32:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wvfdp-0003AV-E9 for emacs-orgmode@gnu.org; Sat, 14 Jun 2014 00:32:38 -0400 Received: from sasl.smtp.pobox.com ([208.72.237.25]:52170) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvfdp-0003AJ-9Q for emacs-orgmode@gnu.org; Sat, 14 Jun 2014 00:32:33 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl0.pobox.com (Postfix) with ESMTP id 3DC511CB80 for ; Sat, 14 Jun 2014 00:32:32 -0400 (EDT) Received: from pb-sasl0.int.icgroup.com (unknown [127.0.0.1]) by pb-sasl0.pobox.com (Postfix) with ESMTP id 3224A1CB7F for ; Sat, 14 Jun 2014 00:32:32 -0400 (EDT) Received: from mail-wg0-f47.google.com (unknown [74.125.82.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by pb-sasl0.pobox.com (Postfix) with ESMTPSA id F0ADE1CB7B for ; Sat, 14 Jun 2014 00:32:27 -0400 (EDT) Received: by mail-wg0-f47.google.com with SMTP id k14so3527587wgh.30 for ; Fri, 13 Jun 2014 21:32:27 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 To: emacs-orgmode --089e01681cd40190a304fbc44892 Content-Type: text/plain; charset=UTF-8 This patch adds support for DEVONthink Pro Office to Org Mac Links. This likely works for all versions of DEVONthink, but that is not tested. Mike >From 50c1ded7cb403cecfe09d4ca0be704ba65e05253 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Sat, 14 Jun 2014 00:13:22 -0400 Subject: [PATCH] Add DEVONthink Pro to Org Mac Link Add DEVONthink Pro Office (likely DEVONthink and DEVONthink Pro also, but I do not have those variants to test) to Org Mac. Support for collecting one (or several) DEVONthink items as Org link and support for opening x-devonthink-item links from withing Org mode. --- contrib/lisp/org-mac-link.el | 73 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el index 2eafa1b..c53871f 100644 --- a/contrib/lisp/org-mac-link.el +++ b/contrib/lisp/org-mac-link.el @@ -9,6 +9,7 @@ ;; Christopher Suckling ;; Daniil Frumin ;; Alan Schmitt +;; Mike McLean ;; ;; ;; Version: 1.1 @@ -58,6 +59,7 @@ ;; Together.app - Grab links to the selected items in the library list ;; Skim.app - Grab a link to the selected page in the topmost pdf document ;; Microsoft Outlook.app - Grab a link to the selected message in the message list +;; DEVONthink Pro Office.app - Grab a link to the selected DEVONthink item(s); open DEVONthink item by reference ;; ;; ;; Installation: @@ -110,6 +112,12 @@ applications and inserting them in org documents" :group 'org-mac-link :type 'boolean) +(defcustom org-mac-grab-devonthink-app-p t + "Enable menu option [d]EVONthink to grab links from DEVONthink Pro Office.app" + :tag "Grab DEVONthink Pro Office.app links" + :group 'org-mac-link + :type 'boolean) + (defcustom org-mac-grab-Addressbook-app-p t "Enable menu option [a]ddressbook to grab links from AddressBook.app" :tag "Grab AddressBook.app links" @@ -192,6 +200,7 @@ applications and inserting them in org documents" (interactive) (let* ((descriptors `(("F" "inder" org-mac-finder-insert-selected ,org-mac-grab-Finder-app-p) ("m" "ail" org-mac-message-insert-selected ,org-mac-grab-Mail-app-p) + ("d" "EVONthink Pro Office" org-mac-devonthink-item-insert-selected ,org-mac-grab-devonthink-app-p) ("o" "utlook" org-mac-outlook-message-insert-selected ,org-mac-grab-Outlook-app-p) ("a" "ddressbook" org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p) ("s" "afari" org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p) @@ -707,6 +716,70 @@ list of mac-outlook:// links to flagged mail after heading." ;; ;; +;; Handle links from DEVONthink Pro Office.app +;; + +(org-add-link-type "x-devonthink-item" 'org-devonthink-item-open) + +(defun org-devonthink-item-open (uid) + "Open the given uid, which is a reference to an item in DEVONthink Pro Office" + (shell-command (concat "open \"x-devonthink-item:" uid "\""))) + +(defun org-as-get-selected-devonthink-item () + "AppleScript to create links to selected items in DEVONthink Pro Office.app." + (do-applescript + (concat + "set theLinkList to {}\n" + "tell application \"DEVONthink Pro\"\n" + "set selectedRecords to selection\n" + "set selectionCount to count of selectedRecords\n" + "if (selectionCount < 1) then\n" + "return\n" + "end if\n" + "repeat with theRecord in selectedRecords\n" + "set theID to uuid of theRecord\n" + "set theURL to \"x-devonthink-item:\" & theID\n" + "set theSubject to name of theRecord\n" + "set theLink to theURL & \"::split::\" & theSubject & \"\n\"\n" + "copy theLink to end of theLinkList\n" + "end repeat\n" + "end tell\n" + "return theLinkList as string" + ))) + +(defun org-mac-devonthink-get-links () + "Create links to the item(s) currently selected in DEVONthink Pro Office. +This will use AppleScript to get the `uuid' and the `name' of the +selected items in DEVONthink Pro Office.app and make links out of +it/them. This function will push the Org-syntax text to the kill +ring, and also return it." + (message "Org Mac DEVONthink: looking for selected items...") + (let* ((as-link-list (org-as-get-selected-devonthink-item)) + (link-list (if as-link-list + (mapcar + (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x (match-string 1 x))) x) + (split-string as-link-list "[\r\n]+")) + nil)) + orglink-list) + (while link-list + (let* ((current-item (pop link-list))) + (message "current item: %s" current-item) + (when (and current-item (not (string= current-item ""))) + (let* ((split-link (split-string current-item "::split::")) + (orglink (org-make-link-string (url-encode-url (car split-link)) (cadr split-link)))) + (push orglink orglink-list))))) + (kill-new (mapconcat 'identity orglink-list "\n")))) + +(defun org-mac-devonthink-item-insert-selected () + "Insert a link to the item(s) currently selected in DEVONthink Pro Office. +This will use AppleScript to get the `uuid'(s) and the name(s) of the +selected items in DEVONthink Pro Office and make link(s) out of it/them." + (interactive) + (insert (org-mac-devonthink-get-links))) + + +;; +;; ;; Handle links from Mail.app ;; -- 2.0.0 --089e01681cd40190a304fbc44892 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
This patch adds support for DEVONthi= nk Pro Office to Org Mac Links. This likely works for all versions of D= EVONthink, but that is not tested.

Mike



=

From 50c1ded7cb403cecfe09d4ca0be704ba65e05253 Mon Sep 1= 7 00:00:00 2001
From: Mike McLean <mike.mclean@pobox.com>
Date: Sat, 14 Jun 2014 00:13:22 -0400
Subject: [PATCH] Add D= EVONthink Pro to Org Mac Link

Add DEVONthink Pro O= ffice (likely DEVONthink and DEVONthink Pro also,
but I do not ha= ve those variants to test) to Org Mac. Support for
collecting one (or several) DEVONthink items as Org link and support
for opening x-devonthink-item links from withing Org mode.
---
=C2=A0contrib/lisp/org-mac-link.el | 73 ++++++++++++++++++= ++++++++++++++++++++++++++
=C2=A01 file changed, 73 insertions(+)

diff -= -git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 2eafa1b..c53871f 100644
--- a/contrib/lisp/org-mac-link.e= l
+++ b/contrib/lisp/org-mac-link.el
@@ -9,6 +9,7 @@
=C2=A0;; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Christopher Suckling <suckli= ng at gmail dot com>
=C2=A0;; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Daniil Frumin <difrumin@gmail.c= om>
=C2=A0;; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Alan Schmitt <alan.schmitt@polytechnique.org&= gt;
+;; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Mike McLean <mike.mclean@pobox.com>
=C2=A0;;
=C2=A0;;
=C2=A0;; Version: 1.1
= @@ -58,6 +59,7 @@
=C2=A0;; Together.app - Grab links to the selec= ted items in the library list
=C2=A0;; Skim.app - Grab a link to = the selected page in the topmost pdf document
=C2=A0;; Microsoft Outlook.app - Grab a link to the selected message i= n the message list
+;; DEVONthink Pro Office.app - Grab a link to= the selected DEVONthink item(s); open DEVONthink item by reference
=C2=A0;;
=C2=A0;;
=C2=A0;; Installation:
@@ -= 110,6 +112,12 @@ applications and inserting them in org documents"
=C2=A0 =C2=A0:group 'org-mac-link
=C2=A0 =C2=A0:type &= #39;boolean)
=C2=A0
+(defcustom org-mac-grab-devonthink-app-p t
+ =C2=A0"Enable = menu option [d]EVONthink to grab links from DEVONthink Pro Office.app"=
+ =C2=A0:tag "Grab DEVONthink Pro Office.app links"
+ =C2=A0:group 'org-mac-link
+ =C2=A0:type 'boolean)
+
=C2=A0(defcustom org-mac-grab-Addressbook-app-p t
=C2=A0 =C2=A0"Enable menu option [a]ddressbook to grab links from A= ddressBook.app"
=C2=A0 =C2=A0:tag "Grab AddressBook.app links"
@@ = -192,6 +200,7 @@ applications and inserting them in org documents"
=C2=A0 =C2=A0(interactive)
=C2=A0 =C2=A0(let* ((descriptor= s `(("F" "inder" org-mac-finder-insert-selected ,org-ma= c-grab-Finder-app-p)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0("m" "ail" org-mac-message-insert-s= elected ,org-mac-grab-Mail-app-p)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0("d" "= ;EVONthink Pro Office" org-mac-devonthink-item-insert-selected ,org-ma= c-grab-devonthink-app-p)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0("o" "utlook" org-mac-outlook-messa= ge-insert-selected ,org-mac-grab-Outlook-app-p)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(&= quot;a" "ddressbook" org-mac-addressbook-insert-selected ,or= g-mac-grab-Addressbook-app-p)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0("s" "afari" org-mac-safari-insert-= frontmost-url ,org-mac-grab-Safari-app-p)
@@ -707,6 +716,70 @@ li= st of mac-outlook:// links to flagged mail after heading."
=C2=A0=0C
=C2=A0;;
=C2=A0;;
+;; Handle l= inks from DEVONthink Pro Office.app
+;;
+
+(o= rg-add-link-type "x-devonthink-item" 'org-devonthink-item-ope= n)
+
+(defun org-devonthink-item-open (uid)
+ =C2=A0"= Open the given uid, which is a reference to an item in DEVONthink Pro Offic= e"
+ =C2=A0(shell-command (concat "open \"x-devont= hink-item:" uid "\"")))
+
+(defun org-as-get-selected-devonthink-item ()
+= =C2=A0"AppleScript to create links to selected items in DEVONthink Pr= o Office.app."
+ =C2=A0(do-applescript
+ =C2=A0 (c= oncat
+ =C2=A0 =C2=A0"set theLinkList to {}\n"
+ =C2=A0 = =C2=A0"tell application \"DEVONthink Pro\"\n"
+ =C2=A0 =C2=A0"set selectedRecords to selection\n"
+ = =C2=A0 =C2=A0"set selectionCount to count of selectedRecords\n"
+ =C2=A0 =C2=A0"if (selectionCount < 1) then\n"
+ =C2=A0 =C2=A0"return\n"
+ =C2=A0 =C2=A0"end if\= n"
+ =C2=A0 =C2=A0"repeat with theRecord in selectedRec= ords\n"
+ =C2=A0 =C2=A0"set theID to uuid of theRecord\= n"
+ =C2=A0 =C2=A0"set theURL to \"x-devonthink-item:\" &a= mp; theID\n"
+ =C2=A0 =C2=A0"set theSubject to name of = theRecord\n"
+ =C2=A0 =C2=A0"set theLink to theURL &= ; \"::split::\" & theSubject & \"\n\"\n"
+ =C2=A0 =C2=A0"copy theLink to end of theLinkList\n"
<= div>+ =C2=A0 =C2=A0"end repeat\n"
+ =C2=A0 =C2=A0"= end tell\n"
+ =C2=A0 =C2=A0"return theLinkList as strin= g"
+ =C2=A0 =C2=A0)))
+
+(defun org-mac-devonthink-get-links ()
+ =C2=A0"= ;Create links to the item(s) currently selected in DEVONthink Pro Office.
+This will use AppleScript to get the `uuid' and the `name'= ; of the
+selected items in DEVONthink Pro Office.app and make links out of
+it/them. This function will push the Org-syntax text to the kill
+ring, and also return it."
+ =C2=A0(message "O= rg Mac DEVONthink: looking for selected items...")
+ =C2=A0(let* ((as-link-list (org-as-get-selected-devonthink-item))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 (link-list (if as-link-list
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(mapcar
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda (x) (if (string-match &qu= ot;\\`\"\\(.*\\)\"\\'" x) (setq x (match-string 1 x))) x= )
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (split-string as-link-list "[\r\n]+"))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0nil))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 orglink-list)
+ =C2=A0 =C2=A0(while link-list
+ =C2=A0 =C2=A0 =C2=A0(let* ((cu= rrent-item (pop link-list)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(message "current item: %s" cur= rent-item)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (and current-item (= not (string=3D current-item "")))
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(let* ((split-link (split-string current-item "::spli= t::"))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (orglink (or= g-make-link-string (url-encode-url (car split-link)) (cadr split-link))))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(push orglink orglink-l= ist)))))
+ =C2=A0 =C2=A0(kill-new (mapconcat 'identity orglin= k-list "\n"))))
+
+(defun org-mac-devonthink-item-insert-selected ()
+ =C2=A0"Insert a link to the item(s) currently selected in DEVONth= ink Pro Office.
+This will use AppleScript to get the `uuid'(= s) and the name(s) of the
+selected items in DEVONthink Pro Office and make link(s) out of it/th= em."
+ =C2=A0(interactive)
+ =C2=A0(insert (org-ma= c-devonthink-get-links)))
+
+=0C
+;;
+;;
=C2=A0;; Handle links from Mail.app
=C2=A0;;
=C2= =A0
--=C2=A0
2.0.0

--089e01681cd40190a304fbc44892--