From 413264882c03af7e9feca4eac959893b50d20e5a Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 5 Nov 2008 17:54:59 +0100 Subject: [PATCH] Introduce function to create links to attachments. This patch introduces two new functions in org-attach.el, `org-attach-expand', and `org-attach-expand-link'. Both take a file name as an argument, assume that this file is an attachment of the current entry, and return the full path to this file or a "file:..." link to it, respectively. With these functions, it becomes very easy to use link abbreviations to create a new link type to attachments: After (setq org-link-abbrev-alist '(("att" . org-attach-expand-link))) links like [[att:file.txt]] will work. --- lisp/ChangeLog | 5 +++++ lisp/org-attach.el | 11 +++++++++++ lisp/org.el | 8 +++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a21b56433..346da6fb4 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2008-11-05 Carsten Dominik + * org.el (org-link-abbrev-alist): Improve customization type. + + * org-attach.el (org-attach-expand-link, org-attach-expand): New + functions. + * org-agenda.el (org-agenda-get-progress): Renamed from `org-get-closed'. Implement searching for state changes as well. (org-agenda-log-mode-items): New option. diff --git a/lisp/org-attach.el b/lisp/org-attach.el index 060de096e..b9993c435 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -334,6 +334,17 @@ See `org-attach-open'." (interactive) (org-attach-open 'in-emacs)) +(defun org-attach-expand (file) + "Return the full path to the current entry's attachment file FILE. +Basically, this adds the path to the attachment directory." + (expand-file-name file (org-attach-dir))) + +(defun org-attach-expand-link (file) + "Return a file link pointing to the current entry's attachment file FILE. +Basically, this adds the path to the attachment directory, and a \"file:\" +prefix." + (concat "file:" (org-attach-expand file))) + (provide 'org-attach) ;; arch-tag: fce93c2e-fe07-4fa3-a905-e10dcc7a6248 diff --git a/lisp/org.el b/lisp/org.el index 3a0f45d1a..6caf9c19f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -849,7 +849,12 @@ only argument to create the link, which should be returned as a string. See the manual for examples." :group 'org-link - :type 'alist) + :type '(repeat + (cons + (string :tag "Protocol") + (choice + (string :tag "Format") + (function))))) (defcustom org-descriptive-links t "Non-nil means, hide link part and only show description of bracket links. @@ -5957,6 +5962,7 @@ Possible values in the list of contexts are `table', `headline', and `item'." (defun org-link-expand-abbrev (link) "Apply replacements as defined in `org-link-abbrev-alist." + (debug) (if (string-match "^\\([a-zA-Z][-_a-zA-Z0-9]*\\)\\(::?\\(.*\\)\\)?$" link) (let* ((key (match-string 1 link)) (as (or (assoc key org-link-abbrev-alist-local)