diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2008-11-05 17:54:59 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2008-11-05 17:54:59 +0100 |
commit | 413264882c03af7e9feca4eac959893b50d20e5a (patch) | |
tree | d89e5bd08ae5b9867928251a8eb90342ce99257a | |
parent | c4e9626bf4c6c7969628b4171e6dccd90429d600 (diff) | |
download | org-mode-413264882c03af7e9feca4eac959893b50d20e5a.tar.gz |
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.
-rwxr-xr-x | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/org-attach.el | 11 | ||||
-rw-r--r-- | lisp/org.el | 8 |
3 files changed, 23 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a21b564..346da6f 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2008-11-05 Carsten Dominik <carsten.dominik@gmail.com> + * 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 060de09..b9993c4 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 3a0f45d..6caf9c1 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) |