From 916a86e8db6ce6b2dc02ea663d70d07f952bbc33 Mon Sep 17 00:00:00 2001 From: Konubinix Date: Fri, 5 Sep 2014 12:19:12 +0200 Subject: [PATCH 2/2] Add a support for linking against an attachment of current entry. * lisp/org-attach.el (org-attach-open-link, org-attach-complete-link): Created Add a call to `org-add-link-type' to make use of the feature. --- lisp/org-attach.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lisp/org-attach.el b/lisp/org-attach.el index eb22b39..3d6dc71 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -494,6 +494,19 @@ Basically, this adds the path to the attachment directory, and a \"file:\" prefix." (concat "file:" (org-attach-expand file))) +(defun org-attach-open-link (file-name) + "Open a link to a file attached to the current entry." + (let ((attach-dir (org-attach-dir t))) + (org-open-file (expand-file-name file-name attach-dir)))) + +(defun org-attach-complete-link () + "Completion on the attachments when creating a link." + (let* ((file (org-attach-find-file "Attached file:"))) + (format "attach:%s" file))) + +;; Install the link type +(org-add-link-type "attach" 'org-attach-open-link) + (provide 'org-attach) ;; Local variables: -- 2.1.0