Browse Source

org-attach: Respect org-attach-commit everywhere

* lisp/org-attach.el (org-attach-delete-one): Respect org-attach-commit
(org-attach-delete-all): Respect org-attach-commit
(org-attach-sync): Respect org-attach-commit

TINYCHANGE
Allen Li 8 years ago
parent
commit
b9b921716b
1 changed files with 6 additions and 3 deletions
  1. 6 3
      lisp/org-attach.el

+ 6 - 3
lisp/org-attach.el

@@ -441,7 +441,8 @@ The attachment is created as an Emacs buffer."
     (unless (file-exists-p file)
     (unless (file-exists-p file)
       (error "No such attachment: %s" file))
       (error "No such attachment: %s" file))
     (delete-file file)
     (delete-file file)
-    (org-attach-commit)))
+    (when org-attach-commit
+      (org-attach-commit))))
 
 
 (defun org-attach-delete-all (&optional force)
 (defun org-attach-delete-all (&optional force)
   "Delete all attachments from the current task.
   "Delete all attachments from the current task.
@@ -457,14 +458,16 @@ A safer way is to open the directory in dired and delete from there."
 		 (y-or-n-p "Are you sure you want to remove all attachments of this entry? ")))
 		 (y-or-n-p "Are you sure you want to remove all attachments of this entry? ")))
       (shell-command (format "rm -fr %s" attach-dir))
       (shell-command (format "rm -fr %s" attach-dir))
       (message "Attachment directory removed")
       (message "Attachment directory removed")
-      (org-attach-commit)
+      (when org-attach-commit
+        (org-attach-commit))
       (org-attach-untag))))
       (org-attach-untag))))
 
 
 (defun org-attach-sync ()
 (defun org-attach-sync ()
   "Synchronize the current tasks with its attachments.
   "Synchronize the current tasks with its attachments.
 This can be used after files have been added externally."
 This can be used after files have been added externally."
   (interactive)
   (interactive)
-  (org-attach-commit)
+  (when org-attach-commit
+    (org-attach-commit))
   (when (and org-attach-file-list-property (not org-attach-inherited))
   (when (and org-attach-file-list-property (not org-attach-inherited))
     (org-entry-delete (point) org-attach-file-list-property))
     (org-entry-delete (point) org-attach-file-list-property))
   (let ((attach-dir (org-attach-dir)))
   (let ((attach-dir (org-attach-dir)))