From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id UDQBKrQrOWOzQQAAbAwnHQ (envelope-from ) for ; Sun, 02 Oct 2022 08:12:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MFYeKbQrOWMIdwAAG6o9tA (envelope-from ) for ; Sun, 02 Oct 2022 08:12:04 +0200 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 500603EC63 for ; Sun, 2 Oct 2022 08:12:04 +0200 (CEST) Received: from localhost ([::1]:57160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oesCp-0004co-7q for larch@yhetil.org; Sun, 02 Oct 2022 02:12:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oesBN-0004cC-2m for emacs-orgmode@gnu.org; Sun, 02 Oct 2022 02:10:34 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:44609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oesBC-0003JO-OZ for emacs-orgmode@gnu.org; Sun, 02 Oct 2022 02:10:32 -0400 Received: by mail-pg1-x533.google.com with SMTP id c7so7328446pgt.11 for ; Sat, 01 Oct 2022 23:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date; bh=YbxMsFYbWTY7U5E0VfGBSBUyYlq3Imz2cHi3Y//MXRg=; b=QCPMJo3FzRtaFxKzT4GVd73trk8dFNoH8tDwe3F3uF1uG/I02/KOSfQWNaJJwcY7W6 A3OG6P1tEbwM3yPIBWkdT6d8IqPqZL0qUTLQQaCcwG4QpRKHELlSypq8uS8kh2Vmymqw yXOag7Vl8JKlDIlvafIeetM7nKAUVJDmT7TqzVtwBbryInw2J4TBnKdplppI4aVfWAa3 7+YAWj1TP/6I7cZNHzXKFZ35hUyUBu7HOy2FnMjKgbfAbmWDZ2dy1Rgjokq6nyL4WPo9 WXDM/OI/tVE632hEj/CTRs/hj8iwAYvq7nXCx4eY9oMpOr59lOZPrrjtmzOceAhTFg/g l4zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date; bh=YbxMsFYbWTY7U5E0VfGBSBUyYlq3Imz2cHi3Y//MXRg=; b=lMVVFkXoUz9ycQq0TisS7ZBcFJMwbDDxiSxb+LnGQJ+wIhIOfJe6UqH5hcmh3Tpf/2 sUC571WBHy9UqvUouyYxWP2Jdjke1baKggVWWLoPSN9IFU+tM7rkV5jLR5PvO8BEpNPK Yjo+S5edytLlmPLqmtnQAFV7EZ03i1fCyp8NC9FoCfRMR6D2PT++U7Xsp5xhsDTN4DYh sd0LSvqMR2SZqKiTqPdNLBbzoeEnd0p5T50Gd8iHL6eS2D6w9Zh6CUsQ81yyGJb2+vrD eBEuBwMHOPKzwV+EWZ2sz2sTLMiWDIgfdnfMa/Dlw2dN8RhXCtDf4xZbM1ZmFIJB04Cl 8QIg== X-Gm-Message-State: ACrzQf14lx6Es13rmyUAKiEjKC6i+2Ieecb9MVDAUiR6kXUD/eRR0V3q 1ZHwVCk6xu1s47yNynF5ikY= X-Google-Smtp-Source: AMsMyM4k2TcdnsDiZ16xf/EXxAQClKeGlRYklTJ7B+czdrx7exFSzx2Bid3IwM1IFLShEMatIeQCbQ== X-Received: by 2002:a05:6a00:1488:b0:542:78a:3f8a with SMTP id v8-20020a056a00148800b00542078a3f8amr16856149pfu.85.1664691021218; Sat, 01 Oct 2022 23:10:21 -0700 (PDT) Received: from localhost ([2409:8970:a80:3a4:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id f1-20020a170902684100b0016d773aae60sm4813952pln.19.2022.10.01.23.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 23:10:20 -0700 (PDT) From: Ihor Radchenko To: Cletip Cletip Cc: Org Mode List , Bhavin Gandhi Subject: [BUG] Storing multiple log notes recursively only keeps the last note (was: Tracking todo state changes AND automatically change to done when all children are done) In-Reply-To: <87y1w4oxul.fsf@localhost> References: <87y1w4oxul.fsf@localhost> Date: Sun, 02 Oct 2022 14:10:57 +0800 Message-ID: <87edvq21se.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=yantar92@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664691124; 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=YbxMsFYbWTY7U5E0VfGBSBUyYlq3Imz2cHi3Y//MXRg=; b=auR2+gJp6yw5KpLicExpCKDYDsnylyELiBuWOBS/ln8d5GiG1WlGJgBM3kqf6x7Uzl+2tW efZz0B6n4PPzbctF0MQeF+/hjEes+QogFCmIof7paEWREQUpVyubU5K8feX+4rMK79i4zt WoPBcZQ+Ife3KQ8hav6A9hw8WFwFWLqpjyIbIiC1Y7VSENeEpOekPUsj96J6u2jLSJOQXl TwD+Dx4V/CUTd/MlCTCX4BQvmy/9KYwCNlTXphHkKhjg7kq3qGOSKgY5ChxG8V2bQLPZdh JAxR72S/o8xZ7l0+EtnKkdYwEVrnfaxTW1CkpWxVZxQcW5xip5qTpDfzNN53FA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664691124; a=rsa-sha256; cv=none; b=PVAcQGbRc6d+c6zv/AFIR3O5LLuhaH3PvFaAPTfj1Q7FM7XDLQxZarnzC82lQvLT6ehVzh hhn7bBybJ+5eH99QFG3GRDTWnZrF+roRjb9Wf52hTdhvSb118DAGNPbDCMAviWK0pfMSkL 4PD7528x0dB8/2OLDRVHycOIdshDhj4y27hvo3tLK6VBZV76Jg7wS80UwRF6jt/jDzmYUh dMhFqGUGUPnr5zGo8TKNFjYndr5hI4TlJN97zdfaanq2XH1VIbESo6tWT51SMNHpKtwxdg O/qyj0DpxtpAVTymYMbnhfxe5rbQEEGZ3+PFrCYj7SkqkEgqo4zWuguX8S9DeA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QCPMJo3F; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.14 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QCPMJo3F; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 500603EC63 X-Spam-Score: -4.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: uQiH0ozcdMPp Ihor Radchenko writes: >> To reproduce this curious behavior, you only need this configuration: > > Confirmed. > > Something inside `org-todo' call in the hook triggers recursive-edit > that, in turn, triggers premature call to post-command-hook containing > note saving function. I was wrong. Your bug has little to do with recursive edits. It is related to the fact that log notes rely on global variables to save the information about the note and record it in `post-command-hook'. What is happening is that `org-add-log-setup' is first called for the child heading and then called for the parent heading in `org-after-todo-statistics-hook'. The second call overwrites the global note state. Later, after Emacs finish executing the user command, `org-store-log-note' is called, but it only sees the overwritten log state - the one for the most recent call to `org-add-log-setup' (parent heading). Thus only parent heading gets the actual note record. We can solve the issue in multiple ways: 1. We may force recording the previous note (if any) at the beginning of `org-add-log-setup'. 2. We may alter `org-add-log-setup' to record the note using recursive edit. This way, every log note will be recorded immediately upon request. 3. We may maintain a log queue and record multiple logs one-by-one in post-command-hook. I personally like option 2, but I am not sure about side effects. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92