From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id eAMcE4aI6mCrSwEAgWs5BA (envelope-from ) for ; Sun, 11 Jul 2021 07:58:30 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id mBXBDoaI6mDySgAAB5/wlQ (envelope-from ) for ; Sun, 11 Jul 2021 05:58:30 +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 A8E991F60E for ; Sun, 11 Jul 2021 07:58:29 +0200 (CEST) Received: from localhost ([::1]:38078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2STz-0000tw-OS for larch@yhetil.org; Sun, 11 Jul 2021 01:58:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2STF-0000re-Ki for emacs-orgmode@gnu.org; Sun, 11 Jul 2021 01:57:41 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:41878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m2STD-0005EL-4h for emacs-orgmode@gnu.org; Sun, 11 Jul 2021 01:57:41 -0400 Received: by mail-lf1-x12e.google.com with SMTP id n14so34037181lfu.8 for ; Sat, 10 Jul 2021 22:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:cc:date:message-id :mime-version; bh=ADq7PJhDs8YaOXIYu1vedSCfp8mgeD/e7FrEvs3WkW4=; b=pljACbZB+LJ9ZaPbJBLgJJvOsXvvSRVeRRgDtJDnf4fKO2xOj60nxgGTpviBP80Bb8 yIrB7hicgz7IR4utjyNbLmlAWNmOBK0GFaef5/RR4bQlr91N7LKHixqmz11Tb//lr74i XPzWKYIVo00b22+DF8hKStD/AqUEvmQnHf1akB/cerZVsNX1XyODHJwRdPE4i/B7HhpF Gc7L7xDYNA8s+ZJRbhplJuCBepHc3fhnXuvIZUMLhmtTRiv3iMEYAIamTM/2a6xLSo7G g3KZaDuvdFKWc6Vd3Ps64MzagOCJtMAYIODR5qA2Dlhgoa8ni6EY/X94m+wiirF8A/au sfQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:cc:date :message-id:mime-version; bh=ADq7PJhDs8YaOXIYu1vedSCfp8mgeD/e7FrEvs3WkW4=; b=Lpw6HmjI1K0m9FNzwOF15KuYpl0DC5KeJGL22py4bEa0kBwhLjAi9NTfixqYvdCCGw k+U1PlGTxYiU4v+FqLY4a1/V87ETlY8TzCLIVaNBt0dTF/K5WjAwv2DSwAzMWIVFGOXQ EfRurvJxD4cX3uzVnSRy4aZ76I6XdRo+gaFmROVUyMYv6UmlVcC6WZVrKxwTKWs1vRdD hFmOjH59AjGjci6xDnnGq2WmEb9wEEXGQ5vLgxDLnoUR+uGEo+JZ6CtPg2nIis0ZG6En StsDvgl49M7/KH4zk+j5521waIyOONO4a97jRth3pKxhv0uRdvGQtkl1kMXVexWo7cor GaDA== X-Gm-Message-State: AOAM530ikruCHc1sifl6OrVhXfwqP4KiLqLNONJ0nNg0hGkm64F/F5nv UactwXUUNOMWNLNPqjw/vUc= X-Google-Smtp-Source: ABdhPJx8vnyGNMpVxafgAW7yFAp5keccK0Xeu8vUnRS2iBHDbZLYrc8RND7mUVEVqRbukwOAN5PFbw== X-Received: by 2002:a19:48d3:: with SMTP id v202mr5116075lfa.617.1625983057417; Sat, 10 Jul 2021 22:57:37 -0700 (PDT) Received: from localhost ([158.255.2.9]) by smtp.gmail.com with ESMTPSA id q11sm1110251ljm.110.2021.07.10.22.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 22:57:36 -0700 (PDT) From: Ihor Radchenko To: Bhavin Gandhi Subject: Re: [PATCH] Re: Bug: Duplicate logbook entry for repeated tasks [9.4.6 (9.4.6-gab9f2a @ /home/gustavo/.emacs.d/elpa/org-9.4.6/)] In-Reply-To: <871r85wgqd.fsf@localhost> References: <877diwbm6a.fsf@gmail.com> <87a6muwa93.fsf@localhost> <874kd1wsc6.fsf@localhost> <871r85wgqd.fsf@localhost> Date: Sun, 11 Jul 2021 13:57:39 +0800 Message-ID: <87wnpxv1d8.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=yantar92@gmail.com; helo=mail-lf1-x12e.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, 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, Gustavo Barros Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625983109; 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=J2v3LVU5kXX85U/RU+XptEkJ6Z6WkAImjpNkjy6v4Ew=; b=N/MlKexcPZLKzkE4mWJJp8Ed4n9hGBAlJASkRGZFFux4uZ/8vomHWz3O8zMTCFAbxifbH/ RMFz0mz1fgwD1wDQleVvCUh4f2FCwPUtT5uPV6aDtxhArS2B4/Pn6RSfT5tzwkmbJLxBXN 8n5AReHeSjQt4PQ8eEsMLuo5HRLPizExNWff0iXzLVgG8//olkXTABSFon80Tp/nBeL+Ov DjWt7sv5kymEbPmc7OyMmMo/FgdHl8Nn283sKqfCvOBnGO8jdjofuoy2cvF55ZwSGzMd4S t/qNuO+lN3eS9Y+FWcztOo16sWmf2AS+VWO691gOLivfxMwIuNmeVSzspGejnw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625983109; a=rsa-sha256; cv=none; b=Av3Vf+YKhhBhXvtFogWFO4/6Q4T3vthHvoPv9L8gLGoMfbbHlENzuQhv8qcN3yYht6nOj2 wYu0PLATX9Y1ocE+EwN5bj49elEjlOJMQArU0b6IaBLso8dQd2lpr5tT/+76ES2xDiYHrI O/rqSqif8xmNO+ARR/N3/YHJlZH4lyn//8Oh8i+qQzRtLLIrTGA1LrciQswqh7LaJcqGpz nKTSyTxnmas1Khe3XS5gDWsVIeQLJwTwTxI/1SDeVK96tGz3Tso1ssaFxeOplCyk2dF7UN AwhG6Bm97CgHOgYcAcm0IEHwE2lxMsz4/pGVP+BF8xwqHMzJH2vEQsp8TF5zag== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=pljACbZB; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Migadu-Spam-Score: 0.79 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=pljACbZB; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Migadu-Queue-Id: A8E991F60E X-Spam-Score: 0.79 X-Migadu-Scanner: scn0.migadu.com X-TUID: R+qCn110V/s3 --=-=-= Content-Type: text/plain And yet another update fixing a typo in previous patch. Sorry --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-duplicate-logbook-entry-for-repeated-tasks.patch >From 89a60d654663b68f1c149fb3341a50191027f45e Mon Sep 17 00:00:00 2001 Message-Id: <89a60d654663b68f1c149fb3341a50191027f45e.1625983004.git.yantar92@gmail.com> From: Ihor Radchenko Date: Sat, 10 Jul 2021 21:43:44 +0800 Subject: [PATCH] Fix duplicate logbook entry for repeated tasks * lisp/org.el (org-add-log-setup): Always run `org-add-log-note' via `post-command-hook'. Otherwise, there is no way to know if a note was requested for `this-command'. Running `org-add-log-note' directly would, for example, break `org-auto-repeat-maybe' as reported in [1]. * lisp/org-agenda.el (org-agenda-todo): Avoid reintroducing the bug fixed in c670379adf. * testing/lisp/test-org.el: Add test checking the reported bug. [1] https://orgmode.org/list/CAOn=hbcaW1R6vtun-E2r4LS=j3dp=VjqmjGtzy8UC1SyPArKbA@mail.gmail.com --- lisp/org-agenda.el | 6 +++++- lisp/org.el | 4 +--- testing/lisp/test-org.el | 23 ++++++++++++++++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 44acd035a..4cd527e5b 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -9433,7 +9433,11 @@ (defun org-agenda-todo (&optional arg) (goto-char pos) (org-show-context 'agenda) (let ((current-prefix-arg arg)) - (call-interactively 'org-todo)) + (call-interactively 'org-todo) + ;; Make sure that log is recorded in current undo. + (when (and org-log-setup + (not (eq org-log-note-how 'note))) + (org-add-log-note))) (and (bolp) (forward-char 1)) (setq newhead (org-get-heading)) (when (and org-agenda-headline-snapshot-before-repeat diff --git a/lisp/org.el b/lisp/org.el index ffcc5945d..3d15771a2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10939,9 +10939,7 @@ (defun org-add-log-setup (&optional purpose state prev-state how extra) org-log-note-extra extra org-log-note-effective-time (org-current-effective-time) org-log-setup t) - (if (eq how 'note) - (add-hook 'post-command-hook 'org-add-log-note 'append) - (org-add-log-note purpose))) + (add-hook 'post-command-hook 'org-add-log-note 'append)) (defun org-skip-over-state-notes () "Skip past the list of State notes in an entry." diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index de3c6f3c9..c2267c32d 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -7396,7 +7396,28 @@ (ert-deftest test-org/auto-repeat-maybe () SCHEDULED: <2012-03-29 Thu +2y> CLOCK: [2012-03-29 Thu 10:00]--[2012-03-29 Thu 16:40] => 6:40" (org-todo "DONE") - (buffer-string)))))) + (buffer-string))))) + ;; Make sure that logbook state change record does not get + ;; duplicated when `org-log-repeat' `org-log-done' are non-nil. + (should + (string-match-p + (rx "* TODO Read book +SCHEDULED: <2021-06-16 Wed +1d> +:PROPERTIES: +:LAST_REPEAT:" (1+ nonl) " +:END: +- State \"DONE\" from \"TODO\"" (1+ nonl) buffer-end) + (let ((org-log-repeat 'time) + (org-todo-keywords '((sequence "TODO" "|" "DONE(d!)"))) + (org-log-into-drawer nil)) + (org-test-with-temp-text + "* TODO Read book +SCHEDULED: <2021-06-15 Tue +1d>" + (org-todo "DONE") + (when (memq 'org-add-log-note post-command-hook) + (org-add-log-note)) + (buffer-string)))))) + ;;; Timestamps API -- 2.31.1 --=-=-=--