From mboxrd@z Thu Jan 1 00:00:00 1970 From: Luciano Passuello Subject: Re: Bug: Archiving items with org-attach-archive-delete set to 'query' always asks for confirmation Date: Sat, 11 Aug 2018 16:53:46 -0300 Message-ID: References: <87zhxtr82r.fsf@kyleam.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1foZyF-00009B-E4 for emacs-orgmode@gnu.org; Sat, 11 Aug 2018 15:54:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1foZyC-0004fU-By for emacs-orgmode@gnu.org; Sat, 11 Aug 2018 15:54:43 -0400 Received: from vps2.litemind.com ([192.159.65.166]:39938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1foZyC-0004HG-77 for emacs-orgmode@gnu.org; Sat, 11 Aug 2018 15:54:40 -0400 Received: from mail-yw1-f45.google.com ([209.85.161.45]:42321) by vps2.litemind.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1foZxW-0006Jm-OM for emacs-orgmode@gnu.org; Sat, 11 Aug 2018 15:53:58 -0400 Received: by mail-yw1-f45.google.com with SMTP id y203-v6so10995749ywd.9 for ; Sat, 11 Aug 2018 12:53:58 -0700 (PDT) In-Reply-To: <87zhxtr82r.fsf@kyleam.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: kyle@kyleam.com Cc: eric@ericabrahamsen.net, Luciano Passuello , emacs-orgmode@gnu.org Hello Kyle, That worked perfectly for all my basic test cases. Thanks! On Fri, Aug 10, 2018 at 10:44 PM Kyle Meyer wrote: > > Luciano Passuello writes: > > > When I set org-attach-archive-delete to query, Org is supposed to ask > > me for confirmation when archiving entries with attachments. However, > > I am always asked for confirmation, regardless if the item has > > attachments in the first place. This is to me clearly undesirable > > behavior. > > I agree, that doesn't sound desirable (though I've never used this > feature, so perhaps I'm missing something). > > > Looking at the source code for org-attach, at line 573, that's indeed > > what code tells us. > > https://code.orgmode.org/bzg/org-mode/src/master/lisp/org-attach.el > > > > My uninformed suggestion is to call org-attach-delete-all without the > > force parameter, using the confirmation code already in > > org-attach-delete-all. > > That would cover the org-attach-archive-delete=query case, but it'd also > ask for confirmation in the org-attach-archive-delete=t case. > > How about this? > > -- >8 -- > Subject: [PATCH] org-attach: Don't query unnecessarily about archiving > > * lisp/org-attach.el (org-attach-archive-delete-maybe): Don't query > about deleting attachments if the entry doesn't have any attachments. > --- > lisp/org-attach.el | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/lisp/org-attach.el b/lisp/org-attach.el > index 192815f4f..53389f782 100644 > --- a/lisp/org-attach.el > +++ b/lisp/org-attach.el > @@ -574,10 +574,8 @@ (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))) > + (when org-attach-archive-delete > + (org-attach-delete-all (not (eq org-attach-archive-delete 'query))))) > > > ;; Attach from dired. > -- > 2.18.0 >