Skip to content

Commit

Permalink
added a helpers for dealing with devonthink tags
Browse files Browse the repository at this point in the history
  • Loading branch information
deactivated committed Feb 14, 2012
1 parent d9aa7c0 commit bf660d4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
10 changes: 10 additions & 0 deletions elisp/org-pandoc.el
Expand Up @@ -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))
Expand Down
31 changes: 29 additions & 2 deletions python/devonmacs/devonthink.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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.