emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add DEVONthink Pro to Org Mac Link
@ 2014-06-14  4:32 Mike McLean
  2014-06-14  6:47 ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Mike McLean @ 2014-06-14  4:32 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 5682 bytes --]

This patch adds support for DEVONthink Pro Office
<http://www.devontechnologies.com/products/devonthink/devonthink-pro-office.html>
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 <mike.mclean@pobox.com>
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 <suckling at gmail dot com>
 ;;          Daniil Frumin <difrumin@gmail.com>
 ;;          Alan Schmitt <alan.schmitt@polytechnique.org>
+;;          Mike McLean <mike.mclean@pobox.com>
 ;;
 ;;
 ;; 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

[-- Attachment #2: Type: text/html, Size: 8288 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add DEVONthink Pro to Org Mac Link
  2014-06-14  4:32 [PATCH] Add DEVONthink Pro to Org Mac Link Mike McLean
@ 2014-06-14  6:47 ` Bastien
  2014-06-14 11:17   ` Mike-Personal
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2014-06-14  6:47 UTC (permalink / raw)
  To: Mike McLean; +Cc: emacs-orgmode

Hi Mike,

Mike McLean <mike.mclean@pobox.com> writes:

> This patch adds support for DEVONthink Pro Office
> <http://www.devontechnologies.com/products/devonthink/devonthink-pro-office.html>
> to Org Mac Links. This likely works for all versions of DEVONthink, but
> that is not tested.

thanks -- the patch got mangled, can you resend it as an attachment or
not use HTML emails?

Thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add DEVONthink Pro to Org Mac Link
  2014-06-14  6:47 ` Bastien
@ 2014-06-14 11:17   ` Mike-Personal
  2014-06-14 12:48     ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Mike-Personal @ 2014-06-14 11:17 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

On June 14, 2014 at 2:47:26 AM, Bastien (bzg@gnu.org(mailto:bzg@gnu.org)) wrote:

> Hi Mike,
>  
> Mike McLean writes:
>  
> > 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.
>  
> thanks -- the patch got mangled, can you resend it as an attachment or
> not use HTML emails?

That’s what I get for 12:30 submissions 😃 

I have attached the patch to this email. 

Mike 



[-- Attachment #2: Add-DEVONthink-Pro-to-Org-Mac-Link.patch --]
[-- Type: application/octet-stream, Size: 5454 bytes --]

From 50c1ded7cb403cecfe09d4ca0be704ba65e05253 Mon Sep 17 00:00:00 2001
From: Mike McLean <mike.mclean@pobox.com>
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 <suckling at gmail dot com>
 ;;          Daniil Frumin <difrumin@gmail.com>
 ;;          Alan Schmitt <alan.schmitt@polytechnique.org>
+;;          Mike McLean <mike.mclean@pobox.com>
 ;;
 ;;
 ;; 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."
 \f
 ;;
 ;;
+;; 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)))
+
+\f
+;;
+;;
 ;; Handle links from Mail.app
 ;;
 
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add DEVONthink Pro to Org Mac Link
  2014-06-14 11:17   ` Mike-Personal
@ 2014-06-14 12:48     ` Bastien
  2014-06-15  0:35       ` Anthony Lander
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2014-06-14 12:48 UTC (permalink / raw)
  To: Mike-Personal; +Cc: emacs-orgmode

Hi Mike,

Mike-Personal <mike.mclean@pobox.com> writes:

> I have attached the patch to this email. 

Applied, thanks.  I updated the changelog:
http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=c57ecf26

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add DEVONthink Pro to Org Mac Link
  2014-06-14 12:48     ` Bastien
@ 2014-06-15  0:35       ` Anthony Lander
  2014-06-15  7:39         ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Anthony Lander @ 2014-06-15  0:35 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode@gnu.org Mode, Mike-Personal

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

Hi Mike,

Thank you for extending org-mac-link. Much appreciated!

And thank you Bastien for taking care of applying the patch.

Have a good weekend,

 -Anthony


On Sat, Jun 14, 2014 at 8:48 AM, Bastien <bzg@gnu.org> wrote:

> Hi Mike,
>
> Mike-Personal <mike.mclean@pobox.com> writes:
>
> > I have attached the patch to this email.
>
> Applied, thanks.  I updated the changelog:
> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=c57ecf26
>
> --
>  Bastien
>
>

[-- Attachment #2: Type: text/html, Size: 1123 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add DEVONthink Pro to Org Mac Link
  2014-06-15  0:35       ` Anthony Lander
@ 2014-06-15  7:39         ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2014-06-15  7:39 UTC (permalink / raw)
  To: Anthony Lander; +Cc: emacs-orgmode@gnu.org Mode, Mike-Personal

Anthony Lander <anthony@landerfamily.ca> writes:

> And thank you Bastien for taking care of applying the patch.

You're welcome!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-15  7:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-14  4:32 [PATCH] Add DEVONthink Pro to Org Mac Link Mike McLean
2014-06-14  6:47 ` Bastien
2014-06-14 11:17   ` Mike-Personal
2014-06-14 12:48     ` Bastien
2014-06-15  0:35       ` Anthony Lander
2014-06-15  7:39         ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).