From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 94MuGDHBrV/fPAAA0tVLHw (envelope-from ) for ; Thu, 12 Nov 2020 23:11:45 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id AC6qEzHBrV9beQAA1q6Kng (envelope-from ) for ; Thu, 12 Nov 2020 23:11:45 +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 aspmx1.migadu.com (Postfix) with ESMTPS id 6B289940981 for ; Thu, 12 Nov 2020 23:11:44 +0000 (UTC) Received: from localhost ([::1]:40082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdLkk-0001Tj-2L for larch@yhetil.org; Thu, 12 Nov 2020 18:11:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdLkA-0001TL-Rl for emacs-orgmode@gnu.org; Thu, 12 Nov 2020 18:11:06 -0500 Received: from pb-smtp20.pobox.com ([173.228.157.52]:64673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdLk5-0006BT-VD for emacs-orgmode@gnu.org; Thu, 12 Nov 2020 18:11:06 -0500 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id C9625F308E; Thu, 12 Nov 2020 18:10:59 -0500 (EST) (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:content-transfer-encoding; s=sasl; bh=lq0uyrEmHwRZ bYgzcat3ej1Y1EY=; b=a5MGMF8Pe3/JqnphRp0sJUmB+f7hSx+iIV5xYQRUfi1F 3q19LkQD5sLuRslaYHhjCNG8JXrJN1sagLIC7/H38UBMCVGbBKPszMtFec5WapGT d0dDYjWZ5MutjqnQEaPZwzJ9mMo+OJUkCr82UDfksm0B9SxttSwHHx/Q0xBwKAo= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id C347BF308D; Thu, 12 Nov 2020 18:10:59 -0500 (EST) (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:content-transfer-encoding; s=mesmtp; bh=VWhmChwM16HmKImTfFcf0Z32TIsr8dJzbPN9KNsgRe0=; b=IUm61NOrc5+8OtzIQV3GYM3egjL4dDvQsATxUMpnSg8D7rubX33R33pK8RJZzITrm6/BumKzrlpitc8AuXXhGw6o6KevROiHWgk+bgguBqgTxT/AwmAUEhl1lKTEFrwVEc58vKf+6q80J/ytk5g5ARk16dNkDXKHk8v2Soe+uu8= 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 12DF1F3088; Thu, 12 Nov 2020 18:10:57 -0500 (EST) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Bob Wilson Subject: Re: Missing argument in org-reset-checkbox-state-subtree? In-Reply-To: References: <56D08D2C-83C1-42C3-A7AF-BCDA797DA277@gmail.com> <87lff76yz5.fsf@kyleam.com> Date: Thu, 12 Nov 2020 18:10:55 -0500 Message-ID: <87d00ii328.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pobox-Relay-ID: 521E607C-253C-11EB-8EC4-E43E2BB96649-24757444!pb-smtp20.pobox.com Received-SPF: pass client-ip=173.228.157.52; envelope-from=kyle@kyleam.com; helo=pb-smtp20.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/12 18:11:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=a5MGMF8P; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=IUm61NOr; dmarc=none; spf=pass (aspmx1.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-Spam-Score: -0.21 X-TUID: KkuhUO8T2RzG Bob Wilson writes: > I use the org-checklist add-on so that marking the task as complete > resets the checkboxes to empty. But I noticed that every time I do so, > it resets the statistics cookies everywhere else in the org file! And > by reset, I mean it replaces things like [5/7] with [0/0]. I have to > do C-u C-c # (org-update-statistics-cookies ALL) to fix it. [ Rearranging things to lead with your complete example first... ] > * Task A [1/2] > ** DONE Subtask A.1 > CLOSED: [2020-11-12 Thu 08:47] > ** TODO Subtask A.2 > * TODO Daily Wind-Down > SCHEDULED: <2020-11-12 Thu 17:00 +1d> > :PROPERTIES: > :RESET_CHECK_BOXES: t > :END: > - [ ] Respond to emails > - [ ] Pat myself on the back > > Marking the Daily Wind-Down as complete resets the buffer so it looks lik= e: > * Task A [0/0] > ** DONE Subtask A.1 > CLOSED: [2020-11-12 Thu 08:47] > ** TODO Subtask A.2 > * TODO Daily Wind-Down > SCHEDULED: <2020-11-13 Fri 17:00 +1d> > :PROPERTIES: > :RESET_CHECK_BOXES: t > :LAST_REPEAT: [2020-11-12 Thu 08:47]=20=20 > :END: > - [ ] Respond to emails > - [ ] Pat myself on the back > > The first line shows the problem: the statistics cookies have updated > to [0/0]. Thanks. I can trigger that as well. So, with the example from , the issue is that, without specifying `all', the _checkbox_ statistics for sibling subheadings do not get updated, just the last one. In contrast, the problem here looks to be that org-update-checkbox-count will result in _todo_ statistics being set to zero, and it doesn't take care of refreshing them. This problem goes away with the higher-level org-update-statistics-cookies because it calls (org-update-checkbox-count 'all) but _then_ follows up with a call to (org-map-entries 'org-update-parent-todo-statistics). > Just for completeness, I will write out my thoughts (and you=E2=80=99ll s= oon > see just how little I know of elisp =E2=80=94 I apologize!). Here is the > org-reset-checkbox-state-subtree as of 9.4: > > (defun org-reset-checkbox-state-subtree () [...] > (org-update-checkbox-count-maybe 'all))))) > > In the last line, it calls org-update-checkbox-count-maybe with =E2=80=98= all > argument. I don=E2=80=99t full understand the single quote part. My > understanding is that it tells lisp not to evaluate the value (which > is good, because there is no all variable defined at this scope). Yes, that's right. (info "(elisp)Quoting") has more details. > My only idea here is that it=E2=80=99s a way of saying, =E2=80=9Cby the t= ime you > actually need this value, I=E2=80=99ll have told you what it is=E2=80=9D.= But what is > relevant is that I don=E2=80=99t think =E2=80=98all is nil; it=E2=80=99s = some kind of > placeholder, so it effectively gets evaluated as true. Or so it seems > to me. > > org-update-checkbox-count-maybe passes this placeholder unmodified to > org-update-checkbox-count which does all the heavy lifting. But > nowhere is the all argument ever modified, it continues to be that > non-nil placeholder, which seems to get evaluated as true. It=E2=80=99s n= ot > clear to me why this placeholder would get passed to the function if > it is never set to anything else. But again, I don=E2=80=99t fully unders= tand > the single quote syntax. In this particular case, org-update-checkbox-count doesn't check for a _specific_ non-nil value, so indeed the only thing that is important is that the value of org-update-checkbox-count's ALL ends up non-nil. t (no need to quote), or any number of things aside from nil, could be passed instead. Using "'all" rather than "t" here is just making things a bit more readable by hinting what the parameter/effect is. > The org-update-checkbox-count is quite complicated (from my > elisp-neophyte perspective), so it is not clear to me why it resets > the statistics cookies to [0/0], but whatever it does, it does it in > the entire file. > > The =E2=80=9Cfix=E2=80=9D that I made was on the first and last lines of = the function: > > (defun org-reset-checkbox-state-subtree (&optional all) > ... > (org-update-checkbox-count-maybe all))))) > > where you can see all I did was remove the single quote from all, and > added all as an optional parameter. Now I feel like this was the wrong > fix, but it does solve my problem! Right, it's problematic because it'd bring back the previous issue with sibling checkbox statistics not being updated. > Maybe the real problem had nothing to do with the entire buffer part, > and was more about why the statistics cookies get updated to [0/0]. That's my current thinking, but I haven't taken a closer look at org-update-checkbox-count yet.