From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yHwVMvNqrV8gNgAA0tVLHw (envelope-from ) for ; Thu, 12 Nov 2020 17:03:47 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id KH3XLfNqrV9KUgAAbx9fmQ (envelope-from ) for ; Thu, 12 Nov 2020 17:03:47 +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 33AB994053D for ; Thu, 12 Nov 2020 17:03:47 +0000 (UTC) Received: from localhost ([::1]:42768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdG0e-0005ZF-I5 for larch@yhetil.org; Thu, 12 Nov 2020 12:03:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdFwz-0002kP-3H for emacs-orgmode@gnu.org; Thu, 12 Nov 2020 11:59:57 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:34331) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kdFww-0004yB-P4 for emacs-orgmode@gnu.org; Thu, 12 Nov 2020 11:59:56 -0500 Received: by mail-pl1-x631.google.com with SMTP id cp9so3108472plb.1 for ; Thu, 12 Nov 2020 08:59:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=VNEHcdm40IysLT4XlN1NXxkF4kwb7kWG80OesUjQbt4=; b=RavLssRMvyEiQfSRSknN36J+TZTUIiCGxaqQqTkkMrNmqdssgGnWHqqSnI5qP0LoXt 9+XqAxtQObYdQchFlk6u4lZBi6HqZ+E1lwYzxuweHvtYJ/HDDIQ6a2efgizXphGns2l5 sTMNtbjBwbkGjhEStHu1uPU8RJlqnwKfunbGFglLrynt2xp+Vo3XbbXnWUZwLHznYOQx o2YH6tdzcBwvKrrKtm0VgkyUFSdK0ojmP6TZ4Ve4/qdlL59woLch+TgrQEH1x2PsWKxm q6icrk7Qurf1NjeIMZlSobG2rvJvvtb2BnftTzUpcdafIHdf3lXpXTlwEFBnVGFK5Nc+ vT6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=VNEHcdm40IysLT4XlN1NXxkF4kwb7kWG80OesUjQbt4=; b=abdvAikz0tvpkC8SfYQ0Tgs5EhdyeXvCxgTHUonewjZMvX4OkHGApMRFOhpHU4bwTY xF9ngGgx26Gu/7qE28eidq4c4/RypwQm4d5L9BRUn9V4MHuYJ7t+Cti5k/ChHKCYg1yh yPTkG80LvANSg+6lnuAFzmfd1whyrmCWHWByMc9u7l+B6RLQ0xLfxE1MXc5qrHkl5lGx ejZCeVp2T0Ic1NwAEgMNKxT7POKLlSQ/6EamUo0wJblulJPD+56v5ev0ztU+lBDlAbzZ p9ZDB0ocBlU5Utm2c2evApUVblnLC6As4+tHn8lG15l34KKvolPyMbcZEEBy6rxAXW9d JgKQ== X-Gm-Message-State: AOAM531UZLuLzoIYwza4dMsAGajWDpBTRzdN1K40q7xatWxV2Kp7pAV3 t+dwowyAs9hmgsiHGVr92A== X-Google-Smtp-Source: ABdhPJzT2pqJXuAItCXmLBHFAFD3m0yoay3q/A7OjSeQrNN6i8RSR9xXa837nCeYI5Th9nYWg1IXPw== X-Received: by 2002:a17:902:d346:b029:d7:de:91fe with SMTP id l6-20020a170902d346b02900d700de91femr270396plk.27.1605200393125; Thu, 12 Nov 2020 08:59:53 -0800 (PST) Received: from ?IPv6:2605:e000:151e:8496:d42c:1770:10f6:1366? ([2605:e000:151e:8496:d42c:1770:10f6:1366]) by smtp.gmail.com with ESMTPSA id w4sm7013331pfq.85.2020.11.12.08.59.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2020 08:59:51 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: Missing argument in org-reset-checkbox-state-subtree? From: Bob Wilson In-Reply-To: <87lff76yz5.fsf@kyleam.com> Date: Thu, 12 Nov 2020 08:59:49 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: References: <56D08D2C-83C1-42C3-A7AF-BCDA797DA277@gmail.com> <87lff76yz5.fsf@kyleam.com> To: Kyle Meyer X-Mailer: Apple Mail (2.3608.120.23.2.4) Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=millstadtf@gmail.com; helo=mail-pl1-x631.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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=gmail.com header.s=20161025 header.b=RavLssRM; dmarc=pass (policy=none) header.from=gmail.com; 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: +2itvA/Q9wxE Hi Kyle, Thanks so much for your thoughtful response. It would probably be = helpful if I gave more context on the problem I was having! I have a daily wind-down routine where I respond to any lingering = emails, etc. So I have an item like: * TODO Daily Wind-Down SCHEDULED: <2020-11-12 Thu 17:00 +1d> - [ ] Respond to emails - [ ] Pat myself on the back 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. I=E2=80=99m new to elisp, but I tried my best to debug what was going = on. I could be completely wrong about the underlying cause, but I was = able to make a change that prevented this phenomenon from occurring. I = thought other people might be having the same problem, but it sounds = like maybe not! Just for completeness, I will write out my thoughts (and you=E2=80=99ll = soon 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 () "Reset all checkboxes in an entry subtree." (interactive "*") (if (org-before-first-heading-p) (error "Not inside a tree") (save-restriction (save-excursion (org-narrow-to-subtree) (org-show-subtree) (goto-char (point-min)) (let ((end (point-max))) (while (< (point) end) (when (org-at-item-checkbox-p) (replace-match "[ ]" t t nil 1)) (beginning-of-line 2))) (org-update-checkbox-count-maybe 'all))))) In the last line, it calls org-update-checkbox-count-maybe with =E2=80=98a= ll 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). My only = idea here is that it=E2=80=99s a way of saying, =E2=80=9Cby the time 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 not = 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 = understand the single quote syntax. 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! 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]. Here is a minimal example that showcases the problem (without my = =E2=80=9Cfix=E2=80=9D in place): * 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 = like: * 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 :END: - [ ] Respond to emails - [ ] Pat myself on the back The first line shows the problem: the statistics cookies have updated to = [0/0]. For what it=E2=80=99s worth, my =E2=80=9Cfix=E2=80=9D may be the wrong = fix, but it does solve the problem! So if anyone else runs into the same = problem, I hope my horrible elisp debugging is mildly helpful! Kind regards, Bob Wilson > On Nov 11, 2020, at 7:22 PM, Kyle Meyer wrote: >=20 > Bob Wilson writes: >=20 >> I=E2=80=99m writing about a possible bug in >> org-reset-checkbox-state-subtree. This function calls >> org-update-checkbox-count-maybe with argument 'all, but this value is >> not defined in the function (or anywhere else that I can see). >=20 > [ I'm looking at the copy on master (e9c3993ee), though org-list.el > hasn't changed since that last release. ] >=20 > org-reset-checkbox-state-subtree calls >=20 > (org-update-checkbox-count-maybe 'all) >=20 > and org-update-checkbox-count-maybe calls >=20 > (org-update-checkbox-count all) >=20 > And org-update-checkbox-count considers ALL, so I'm not spotting > anything that's undefined. >=20 >> I=E2=80=99d like this value to be nil because I don=E2=80=99t want to = update the >> statistics cookies in the entire buffer, but I don=E2=80=99t see a = way to do >> this (pardon my limited elisp). My workaround is to add an optional >> all argument to org-reset-checkbox-state-subtree and pass it to >> org-update-checkbox-count-maybe. >=20 > Why does refreshing the stats for the entire buffer cause a problem = for > you? >=20 >> This seems like the desired functionality unless I=E2=80=99m missing >> something. Is the current implementation intentional? >=20 > Yes, the change was made with a0bc3bdeb (org-list: fix update of > check-boxes cookies in whole trees, 2011-06-20). The example that > prompted that change was reported at > . >=20 > Here's a reduced example: >=20 > * a > ** aa [1/1] > - [X] l > ** ab [1/1] > - [X] m >=20 > Calling org-reset-checkbox-state-subtree with point at the top-level = "a" > should uncheck l and m and the stats of both subheadings should go to > [0/1]: >=20 > * a > ** aa [0/1] > - [ ] l > ** ab [0/1] > - [ ] m >=20 > If you were to drop `all' from -reset-checkbox-state-subtree's the = call > to -update-checkbox-count-maybe, the result would instead be >=20 > * a > ** aa [1/1] > - [ ] l > ** ab [0/1] > - [ ] m