diff options
author | Bastien Guerry <bzg@altern.org> | 2011-03-03 11:17:55 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2011-03-03 11:17:55 +0100 |
commit | 85d4d65af092e09bbf9dd11dad7c1f475ef56f55 (patch) | |
tree | defc0013c466ac0c8d5a6d55d97a9530dfcf05a0 | |
parent | dc60852d24b16555466214712181351e11b68e7c (diff) | |
download | org-mode-85d4d65af092e09bbf9dd11dad7c1f475ef56f55.tar.gz |
Allow to store a link in `org-stored-links' to a newly attached file.
* org-attach.el (org-attach-store-link-p): New variable.
(org-attach-store-link): New function.
(org-attach-attach): When `org-attach-store-link-p' is
non-nil, store a link in `org-stored-links' to a newly
attached file.
Thanks to Darlan Cavalcante Moreira for this idea.
-rw-r--r-- | lisp/org-attach.el | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lisp/org-attach.el b/lisp/org-attach.el index a894064..a48dad3 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -96,10 +96,14 @@ ln create a hard link. Note that this is not supported :group 'org-attach :type 'boolean) - (defvar org-attach-inherited nil "Indicates if the last access to the attachment directory was inherited.") +(defcustom org-attach-store-link-p nil + "Non-nil means store a link to a file when attaching it." + :group 'org-attach + :type 'boolean) + ;;;###autoload (defun org-attach () "The dispatcher for attachment commands. @@ -264,6 +268,14 @@ This checks for the existence of a \".git\" directory in that directory." "Turn the autotag off." (org-attach-tag 'off)) +(defun org-attach-store-link (file) + "Add a link to `org-stored-link' when attaching a file. +Only do this when `org-attach-store-link-p' is non-nil." + (setq org-stored-links + (cons (list (org-attach-expand-link file) + (file-name-nondirectory file)) + org-stored-links))) + (defun org-attach-attach (file &optional visit-dir method) "Move/copy/link FILE into the attachment directory of the current task. If VISIT-DIR is non-nil, visit the directory with dired. @@ -282,6 +294,8 @@ METHOD may be `cp', `mv', or `ln', default taken from `org-attach-method'." ((eq method 'ln) (add-name-to-file file fname))) (org-attach-commit) (org-attach-tag) + (when org-attach-store-link-p + (org-attach-store-link file)) (if visit-dir (dired attach-dir) (message "File \"%s\" is now a task attachment." basename))))) |