From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms98 with LMTPS id aARoIZ/Kil4qGAAAGDD2mg (envelope-from ) for ; Mon, 06 Apr 2020 06:22:23 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id aPXfA5/Kil5bCQAA1q6Kng (envelope-from ) for ; Mon, 06 Apr 2020 06:22:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id BEAB5683CF8 for ; Mon, 6 Apr 2020 05:52:05 +0000 (UTC) Received: from localhost ([::1]:54950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLKfy-0000Ak-Ns for larch@yhetil.org; Mon, 06 Apr 2020 01:52:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46247) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLKfc-0000AY-Ff for emacs-orgmode@gnu.org; Mon, 06 Apr 2020 01:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLKfa-0004DU-U5 for emacs-orgmode@gnu.org; Mon, 06 Apr 2020 01:51:40 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:63307) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLKfa-0004Bg-NP for emacs-orgmode@gnu.org; Mon, 06 Apr 2020 01:51:38 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 5A9EEBB0C5; Mon, 6 Apr 2020 01:51:35 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=VNEdWuJQoF/Ige4zFa5qC/eOXCY=; b=SnkQuc iLtXt+uqh0OsJONl3jNCPBZLs02XUd0fNW78xQc/MtsbznH8JSp4dGI4D3YBFqE2 ZDQMu/Bt6bHXsDDJXrYWc5iCsaTxFnBU9NykqXpNuaBvXE1OFGKpIDsleEeP1xR9 580vNlTfbOp4h9ZH4uoyaOqIK83plkUZLHKG0= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 5347CBB0C4; Mon, 6 Apr 2020 01:51:35 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=bzjiu++EDrImO1j8ENP3kTTBTC/olmVTXhCy33O03YY=; b=E/3mVP1UPWR2pHcSZVXMOW7iICmrqXnGs1FT8bSbyIIFd+DsFV5bV06fYp3IHNXCD1Sclg55P8NTjyXZtCSF3U9tUFC4/1j+qg8rHan/YQEKUQLlcJvBlhLZ2B9B87SD9V20ghsjaZ7i3DL8S7Ir2ASoo4e5Rla/qUPx/kbEpGY= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id B8D1ABB0C3; Mon, 6 Apr 2020 01:51:32 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: No Wayman Subject: Re: Bug: org-archive-subtree-save-file-p logic [9.3.6 (release_9.3.6-399-ge6df03 @ /home/n/.emacs.d/straight/build/org/)] In-Reply-To: <87zhcybjz5.fsf@gmail.com> References: <87zhcybjz5.fsf@gmail.com> Date: Mon, 06 Apr 2020 05:51:30 +0000 Message-ID: <87lfn917rx.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: AB353782-77CA-11EA-9191-B0405B776F7B-24757444!pb-smtp20.pobox.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 173.228.157.52 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=default; t=1586152326; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=5+RkWZkEW6U+ovWXW48L0i9wirUg2jg/I/15jbg+Zw4=; b=P064afQpHHOvz2itHKoiapYyYzgF5aTaPg6LT2+VI4tKRhYdh/45Ny1XQW47DMUKKsP2D0 iNf/CbCRFQ7FCBgT5TLoAkkHUvHzmjB1qtFJ2NBR1MKhTTx/yMZ0Z2dB7E8ZM8t8YK0Wsx NSSY4Ii/Jo8WrnamklL866VpmR9gCyA= ARC-Seal: i=1; s=default; d=yhetil.org; t=1586152326; a=rsa-sha256; cv=none; b=K194ByVUYluJ60+66OD0Fch9baqenR6BFfc2JmSMxPgqdDqG2P5GmoTOb0FPOGYg8LxFhw 9Om5Z5awgYw5nOebcTlAktkUdEADAOnWrJnsRLcbpCBFZPn5KPHV61NaYCppBl+XBGwm2Z 3+Fru0kwbkhdpy6SPrYHjnRLfCEKAKg= ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=SnkQuc i; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=E/3mVP1U; dmarc=none; spf=pass (aspmx2.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scanner: scn0 X-Spam-Score: -1.21 Authentication-Results: aspmx2.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=SnkQuc i; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=E/3mVP1U; dmarc=none; spf=pass (aspmx2.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.21 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.58420181561633]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.33), country: US(-0.01), ip: 209.51.188.17(-0.58)]; ARC_SIGNED(0.00)[i=1]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[pobox.com:+,kyleam.com:+]; MAILLIST(-0.20)[mailman]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[kyle@kyleam.com,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[pobox.com:s=sasl,kyleam.com:s=mesmtp]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[kyleam.com]; HAS_LIST_UNSUB(-0.01)[]; RCVD_COUNT_SEVEN(0.00)[8]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: /SarJYVBMedF No Wayman writes: > The logic for saving the archive buffer in org-archive-subtree > does not consider the (default) value of 'from-org for > org-archive-subtree-save-file-p. Hmm, indeed, the change from 3d0282ef8 (New option `org-archive-subtree-save-file-p', 2020-01-31) looks incomplete. > While patching this, I realized I'm not sure I understand the > intended logic of each value for org-archive-subtree-save-file-p. >From digging a bit, I think the history went like this: * All the way back in 4be4c5623 (version 4.12a, 2008-01-31), org-archive-subtree saved the archive buffer, except when it was the current buffer. [ The next two aren't relevant for the save part, but I'm noting because we should cleaned them up. ] * As of bf09955fe (Bugfix for `org-archive-subtree', 2008-03-01), the buffer was killed after being saved. * 343f3c478 (Keep archive buffer after archiving something to it, 2009-10-28) reverted the killing, though it left behind a stale comment saying the buffer will be killed. * 63f6e851b (Do not save target buffer after archiving subtree, 2017-11-25) stopped saving the buffer for performance reasons. * Some users preferred the older behavior. An associated Debian bug was opened. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=887332 https://yhetil.org/orgmode/f74fce15-c2ea-048e-b2ef-7ad40e717c89@arfer.net/ In response, Bastien committed 3d0282ef8 to offer more control over when saving happens. > When setting it to 't', the defcustom :tag string claims "Always > save the archive buffer". > This is not the case if archiving from within the current buffer. > Perhaps a clearer :tag string? > > #+begin_src emacs-lisp > (defcustom org-archive-subtree-save-file-p 'from-org > ;;... > (const :tag "Save the archive buffer unless it is the current > buffer" t) > ;;... > )) > #+end_src Yeah, I'd say that's an improvement, though the same "unless it is the current buffer" would be true for from-org as well, were it wired up. > The value 'from-org also still saves the archive buffer when > archiving from a buffer that is not in Org mode. I'm confused by this statement. To me it looks like save-buffer will _never_ be called when org-archive-subtree-save-file-p is from-org: (unless (eq this-buffer buffer) (when (or (eq org-archive-subtree-save-file-p t) (and (boundp 'org-archive-from-agenda) (eq org-archive-subtree-save-file-p 'from-agenda))) (save-buffer))) > I'm not entirely sure of its purpose. If the intent is to allow an > option that prevents saving only when archiving from the agenda, > I suggest a single option excluding that case and saving for > other, non-nil values: Based on the history above, I believe the main purpose is to give users a way to reverse the "no saving" behavior made in 63f6e851b (Do not save target buffer after archiving subtree, 2017-11-25). I'm _guessing_ that, on top of that, the idea adding a from-agenda value was that some users may want to save only when archiving from the agenda, because in that case they're a bit removed from the buffer and might not think to save it, or something along those lines. > #+begin_src emacs-lisp > (defcustom org-archive-subtree-save-file-p 'unless-agenda > "Conditionally save the archive file after archiving a subtree. > The value 'unless-agenda prevents saving from the agenda-view. > Other non-nil values save the archive buffer unless it is the > current buffer." > :group 'org-archive > :package-version '(Org . "9.4") > :type '(choice > (const :tag "Do not save archive buffer when archiving > from an agenda view" unless-agenda) > (const :tag "Save the archive buffer unless it is the > current buffer" t) > (const :tag "Do not save the archive buffer"))) > #+end_src > > Then the saving logic in org-archive-subtree becomes: > > #+begin_src emacs-lisp > (when org-archive-subtree-save-file-p > (unless (or (eq buffer this-buffer) > (and (eq org-archive-subtree-save-file-p > 'unless-agenda) > ;;bound when called from org-agenda.el > (boundp 'org-archive-from-agenda))) > (save-buffer))) > #+end_src Assuming what I said above is true, I think what you propose here loses the ability to save only when archiving from the agenda. And more importantly, users would not be able to give a blanket "don't save" in order to retain the behavior introduced by 63f6e851b (Do not save target buffer after archiving subtree, 2017-11-25).