summaryrefslogtreecommitdiff
path: root/lisp/org/org-attach.el
diff options
context:
space:
mode:
authorBastien Guerry <bastien1@free.fr>2011-07-28 17:13:49 +0200
committerBastien Guerry <bastien1@free.fr>2011-07-28 17:13:49 +0200
commit3ab2c837b302b01fff610f7b83050ab7e703477c (patch)
treeefa67ed523bbda4d41488ae6b9ad2782941ddcf2 /lisp/org/org-attach.el
parent44a8054f971837447e80d618b6e0c2a77778a2ee (diff)
downloademacs-3ab2c837b302b01fff610f7b83050ab7e703477c.tar.gz
emacs-3ab2c837b302b01fff610f7b83050ab7e703477c.tar.bz2
emacs-3ab2c837b302b01fff610f7b83050ab7e703477c.zip
Merge changes from Org 7.4 to current Org 7.7.
Diffstat (limited to 'lisp/org/org-attach.el')
-rw-r--r--lisp/org/org-attach.el34
1 files changed, 27 insertions, 7 deletions
diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el
index ae97db20f70..809ec159496 100644
--- a/lisp/org/org-attach.el
+++ b/lisp/org/org-attach.el
@@ -1,10 +1,10 @@
;;; org-attach.el --- Manage file attachments to org-mode tasks
-;; Copyright (C) 2008-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@newartisans.com>
;; Keywords: org data task
-;; Version: 7.4
+;; Version: 7.7
;; This file is part of GNU Emacs.
;;
@@ -96,10 +96,17 @@ 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 '(choice
+ (const :tag "Don't store link" nil)
+ (const :tag "Link to origin location" t)
+ (const :tag "Link to the attach-dir location" 'attached)))
+
;;;###autoload
(defun org-attach ()
"The dispatcher for attachment commands.
@@ -246,10 +253,10 @@ This checks for the existence of a \".git\" directory in that directory."
(cd dir)
(shell-command "git add .")
(shell-command "git ls-files --deleted" t)
- (mapc (lambda (file)
- (unless (string= file "")
- (shell-command
- (concat "git rm \"" file "\""))))
+ (mapc #'(lambda (file)
+ (unless (string= file "")
+ (shell-command
+ (concat "git rm \"" file "\""))))
(split-string (buffer-string) "\n"))
(shell-command "git commit -m 'Synchronized attachments'")))))
@@ -264,6 +271,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 +297,10 @@ 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)
+ (cond ((eq org-attach-store-link-p 'attached)
+ (org-attach-store-link fname))
+ ((eq org-attach-store-link-p t)
+ (org-attach-store-link file)))
(if visit-dir
(dired attach-dir)
(message "File \"%s\" is now a task attachment." basename)))))
@@ -418,4 +437,5 @@ prefix."
(provide 'org-attach)
+;; arch-tag: fce93c2e-fe07-4fa3-a905-e10dcc7a6248
;;; org-attach.el ends here