Permalink
Browse files

added a helpers for dealing with devonthink tags

  • Loading branch information...
1 parent d9aa7c0 commit bf660d47b99c3039160fa227b3b433dd013f1477 @deactivated committed Feb 14, 2012
Showing with 39 additions and 2 deletions.
  1. +10 −0 elisp/org-pandoc.el
  2. +29 −2 python/devonmacs/devonthink.py
View
@@ -54,6 +54,16 @@ end tell'" app)))
(buffer-substring-no-properties (point) (line-end-position)))))
+(defun org-pandoc-document-tags (&optional buffer)
+ (with-current-buffer (or buffer (current-buffer))
+ (save-excursion
+ (goto-char (point-min))
+ (if (re-search-forward "#\\+FILETAGS: *" nil t)
+ (org-split-string
+ (buffer-substring-no-properties (point) (line-end-position)) ":")
+ '()))))
+
+
(defun org-pandoc-roundtrip-append (html-buffer source-buffer)
(with-current-buffer html-buffer
(goto-char (point-max))
@@ -2,7 +2,8 @@
from appscript import *
-__all__ = ["quicksearch", "url", "create_record"]
+__all__ = ["quicksearch", "url", "create_record", "update_record",
+ "get_record", "append_tags"]
def quicksearch(text):
@@ -31,7 +32,7 @@ def url(text):
url.interaction = 'MSearch: '
-def create_record(name, type, content=None, fn=None):
+def create_record(name, type, content=None, fn=None, tags=()):
sources = {
"html": k.source,
"rich": k.rich_text,
@@ -50,5 +51,31 @@ def create_record(name, type, content=None, fn=None):
record = dtpo.create_record_with({
k.name: name.decode('utf8'),
k.type: types[type],
+ k.tags: tags,
sources[type]: content.decode('utf8')})
return record.uuid.get(), record.path.get()
+
+
+def update_record(uuid, **kwargs):
+ dtpo = app('DEVONthink Pro.app')
+ record = dtpo.get_record_with_uuid(uuid)
+ for k, v in kwargs.iteritems():
+ if hasattr(record, k):
+ getattr(record, k).set(v)
+
+
+def get_record(uuid):
+ keys = ["uuid", "name", "tags", "path"]
+
+ dtpo = app('DEVONthink Pro.app')
+ record = dtpo.get_record_with_uuid(uuid)
+
+ return [(k, getattr(record, k).get()) for k in keys]
+
+
+def append_tags(uuid, tags):
+ dtpo = app('DEVONthink Pro.app')
+ record = dtpo.get_record_with_uuid(uuid)
+
+ current_tags = record.tags.get()
+ record.tags.set(current_tags + tags)

0 comments on commit bf660d4

Please sign in to comment.