emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH]: org-attach.el: Use `force' arg everywhere in `org-attach-de


From: Kyle Meyer
Subject: Re: [PATCH]: org-attach.el: Use `force' arg everywhere in `org-attach-delete-all'
Date: Wed, 04 Mar 2020 04:10:58 +0000

Tim Visher <address@hidden> writes:

> * 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.

Sounds reasonable to me.

>  (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."

While I think any reader would know what you meant by "truthy",
"non-nil" would be more standard/familiar in the context of elisp
docstrings.  Or, given this is an interactive command, "With prefix
argument FORCE" or something along those lines.

>    (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)

With Emacs 25 or newer and the default font-lock levels, you should see
"t)" highlighted with font-lock-warning-face because t is "hidden behind
a deeper element".  You could fix it by moving t to its own line, but to
my eyes keeping the entire delete-directory on a single line would be
readable enough.

Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]