Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 51 lines (41 sloc) 1.567 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
;;; org-devonthink.el - Support for links to dtp messages by their UUID

;; version 1.1, by John Wiegley <johnw@gnu.org>

(require 'org)

(org-add-link-type "x-devonthink-item" 'org-dtp-open)

(defun org-dtp-open (record-location)
  "Visit the dtp message with the given Message-ID."
  (shell-command (concat "open x-devonthink-item:" record-location)))

(defun org-get-dtp-link (&optional given-name)
  (interactive)
  (let ((name (or given-name
                  (substring (do-applescript (format "
tell application \"DEVONthink Pro\"
get name of content record
end tell")) 1 -1)))
(location (substring (do-applescript (format "
tell application \"DEVONthink Pro\"
get uuid of content record
end tell")) 1 -1)))
    (org-make-link-string
     (concat "x-devonthink-item://" location) name)))

(defun org-insert-dtp-link ()
  (interactive)
  (let (name)
    (when (region-active-p)
      (setq name (buffer-substring-no-properties (region-beginning)
                                                 (region-end)))
      (delete-region (region-beginning) (region-end)))
    (insert (org-get-dtp-link name))))

(defun org-dtp-store-link ()
  "Store a link to an dtp e-mail message by Message-ID."
  (let ((link-name
(with-temp-buffer
(clipboard-yank)
(buffer-string))))
    (org-store-link-props
     :type "x-devonthink-item"
     :link (cons (concat "x-devonthink-item://" link-name)
(concat "x-devonthink-item://" link-name))
     :description (file-name-nondirectory link-name))))

(provide 'org-devonthink)

;;; org-devonthink.el ends here
Something went wrong with that request. Please try again.