summaryrefslogtreecommitdiffhomepage
path: root/sys/jao-devon.el
diff options
context:
space:
mode:
Diffstat (limited to 'sys/jao-devon.el')
-rw-r--r--sys/jao-devon.el42
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/jao-devon.el b/sys/jao-devon.el
new file mode 100644
index 0000000..417cb6d
--- /dev/null
+++ b/sys/jao-devon.el
@@ -0,0 +1,42 @@
+;; DEVONthink interaction
+
+(require 'jao-applescript)
+
+(defconst *jao-devon-sep* "####")
+
+(defun jao-devon-path (dvp)
+ (car (split-string dvp *jao-devon-sep*)))
+(defun jao-devon-url (dvp)
+ (cadr (split-string dvp *jao-devon-sep*)))
+(defun jao-devon-name (dvp)
+ (car (last (split-string (jao-devon-path dvp) "/"))))
+
+(defun jao-devon-make-dvp (path url) (concat path *jao-devon-sep* name))
+(defun jao-devon-dvp-p (dvp)
+ (and (stringp dvp)
+ (string-match (concat "^/.+" *jao-devon-sep*) dvp)))
+
+(defconst *jao-devon-sel-as*
+ (concat "set rs to the selection
+ set r to item 1 of rs
+ set rn to the name of r
+ set rl to the location of r
+ set ru to the URL of r
+ rl & rn & \"" *jao-devon-sep* "\" & ru"))
+
+(defun jao-devon-selection ()
+ (interactive)
+ (jao-as-tell-app "DEVONThink Pro" *jao-devon-sel-as*))
+
+(defun jao-devon-open-as (path)
+ (concat "set r to get record at \"" path "\""
+ "\n open window for record r\n activate"))
+
+(defun jao-devon-open (dvp)
+ (if (eq system-type 'darwin)
+ (let ((path (jao-devon-path dvp)))
+ (when path
+ (jao-as-tell-app "DEVONThink Pro" (jao-devon-open-as path) t)))
+ (browse-url (jao-devon-url dvp))))
+
+(provide 'jao-devon)