forked from mirrors/org-mode
org-attach: Maybe delete heading attachments when archiving
* lisp/org-attach.el (org-attach-archive-delete): New option controlling what to do with attachments when archiving. (org-attach-archive-delete-maybe): New function that runs as a hook on org-archive-hook. Checks the value of `org-attach-archive-delete', and behaves accordingly.
This commit is contained in:
parent
a7c72e0de5
commit
1feafbfa99
|
@ -120,6 +120,17 @@ lns create a symbol link. Note that this is not supported
|
|||
(const :tag "Link to origin location" t)
|
||||
(const :tag "Link to the attach-dir location" attached)))
|
||||
|
||||
(defcustom org-attach-archive-delete nil
|
||||
"Non-nil means attachments are deleted upon archiving a subtree.
|
||||
When set to `query', ask the user instead."
|
||||
:group 'org-attach
|
||||
:version "25.1"
|
||||
:package-version '(Org . "8.3")
|
||||
:type '(choice
|
||||
(const :tag "Never delete attachments" nil)
|
||||
(const :tag "Always delete attachments" t)
|
||||
(const :tag "Query the user" query)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-attach ()
|
||||
"The dispatcher for attachment commands.
|
||||
|
@ -475,6 +486,17 @@ Basically, this adds the path to the attachment directory, and a \"file:\"
|
|||
prefix."
|
||||
(concat "file:" (org-attach-expand file)))
|
||||
|
||||
(defun org-attach-archive-delete-maybe ()
|
||||
"Maybe delete subtree attachments when archiving.
|
||||
This function is called by `org-archive-hook'. The option
|
||||
`org-attach-archive-delete' controls its behavior."
|
||||
(when (if (eq org-attach-archive-delete 'query)
|
||||
(yes-or-no-p "Delete all attachments? ")
|
||||
org-attach-archive-delete)
|
||||
(org-attach-delete-all t)))
|
||||
|
||||
(add-hook 'org-archive-hook 'org-attach-archive-delete-maybe)
|
||||
|
||||
(provide 'org-attach)
|
||||
|
||||
;; Local variables:
|
||||
|
|
Loading…
Reference in New Issue