emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH]: org-attach.el: Use `force' arg everywhere in `org-attach-delete-all'
@ 2020-03-03 14:24 Tim Visher
  2020-03-04  4:10 ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Visher @ 2020-03-03 14:24 UTC (permalink / raw)
  To: Emacs Org Mode mailing list


[-- Attachment #1.1: Type: text/plain, Size: 1935 bytes --]

From 9a8abeee9109f24d8643990a561c16c8b402b1b1 Mon Sep 17 00:00:00 2001
From: Tim Visher <tim.visher@gmail.com>
Date: Tue, 3 Mar 2020 09:14:44 -0500
Subject: [PATCH] org-attach.el: Use `force' arg everywhere in
 `org-attach-delete-all'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-attach.el (org-attach-delete-all): Use `force' arg
throughout function.

`org-attach-delete-all` advertised a `force` option but passing it
only forced its way past the initial "Really remove all…" query.  This
was unexpected and not properly documented.

This extends the use of the `force` argument to the `delete-directory`
call and documents its meaning in the docstring.

TINYCHANGE
---
 lisp/org-attach.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 429d69021..26099aab3 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -574,13 +574,17 @@ The attachment is created as an Emacs buffer."
 (defun org-attach-delete-all (&optional force)
   "Delete all attachments from the current outline node.
 This actually deletes the entire attachment directory.
-A safer way is to open the directory in dired and delete from there."
+A safer way is to open the directory in dired and delete from there.
+
+If FORCE is truthy, directory will be recursively deleted with no
+prompts."
   (interactive "P")
   (let ((attach-dir (org-attach-dir)))
     (when (and attach-dir
        (or force
    (yes-or-no-p "Really remove all attachments of this entry? ")))
-      (delete-directory attach-dir (yes-or-no-p "Recursive?") t)
+      (delete-directory attach-dir (or force
+       (yes-or-no-p "Recursive?")) t)
       (message "Attachment directory removed")
       (run-hook-with-args 'org-attach-after-change-hook attach-dir)
       (org-attach-untag))))
-- 
2.19.1

[-- Attachment #1.2: Type: text/html, Size: 2259 bytes --]

[-- Attachment #2: 0001-org-attach.el-Use-force-arg-everywhere-in-org-attach.patch --]
[-- Type: application/octet-stream, Size: 1893 bytes --]

From 9a8abeee9109f24d8643990a561c16c8b402b1b1 Mon Sep 17 00:00:00 2001
From: Tim Visher <tim.visher@gmail.com>
Date: Tue, 3 Mar 2020 09:14:44 -0500
Subject: [PATCH] org-attach.el: Use `force' arg everywhere in
 `org-attach-delete-all'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-attach.el (org-attach-delete-all): Use `force' arg
throughout function.

`org-attach-delete-all` advertised a `force` option but passing it
only forced its way past the initial "Really remove all…" query.  This
was unexpected and not properly documented.

This extends the use of the `force` argument to the `delete-directory`
call and documents its meaning in the docstring.

TINYCHANGE
---
 lisp/org-attach.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 429d69021..26099aab3 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -574,13 +574,17 @@ The attachment is created as an Emacs buffer."
 (defun org-attach-delete-all (&optional force)
   "Delete all attachments from the current outline node.
 This actually deletes the entire attachment directory.
-A safer way is to open the directory in dired and delete from there."
+A safer way is to open the directory in dired and delete from there.
+
+If FORCE is truthy, directory will be recursively deleted with no
+prompts."
   (interactive "P")
   (let ((attach-dir (org-attach-dir)))
     (when (and attach-dir
 	       (or force
 		   (yes-or-no-p "Really remove all attachments of this entry? ")))
-      (delete-directory attach-dir (yes-or-no-p "Recursive?") t)
+      (delete-directory attach-dir (or force
+				       (yes-or-no-p "Recursive?")) t)
       (message "Attachment directory removed")
       (run-hook-with-args 'org-attach-after-change-hook attach-dir)
       (org-attach-untag))))
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-06  4:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-03 14:24 [PATCH]: org-attach.el: Use `force' arg everywhere in `org-attach-delete-all' Tim Visher
2020-03-04  4:10 ` Kyle Meyer
2020-03-04 18:27   ` Tim Visher
2020-03-06  4:26     ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).