Emacs Org-mode DT import


I am trying to import an emacs org-mode article that I wrote into DT with a keybinding shortcut. I found this code on the net:

(defun org-export-to-devonthink (arg)
  "Call `org-export-to-devonthink` with output to a temporary buffer.
   No file is created."
  (interactive "P")
  (let (content)
    (org-export-as-html arg nil nil "*Org HTML Export*")
    (switch-to-buffer "*Org HTML Export*")
    (setq content (buffer-string))
    (kill-buffer "*Org HTML Export*")
    (setq content (replace-regexp-in-string (regexp-quote "\"") "\\\"" content t t))
     (format "tell application id \"com.devon-technologies.thinkpro2\"
create record with {name:get title of \"%s\",
type:html, source:\"%s\", url:\"%s\"} in current group
end tell
" content content (buffer-file-name)))

(global-set-key [f8] 'org-export-to-devonthink)

But I get just an “AppleScript error 1” message when I run it. Can someone help me with the script part ?

Where did you find this code, are there any instructions how to use it?

Google says this might be the source, but there are differences from the code posted by the OP.


Thanks for that link. The code works now!