From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sFGOGo+E6mAdQgEAgWs5BA (envelope-from ) for ; Sun, 11 Jul 2021 07:41:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id eMarFY+E6mAzIQAA1q6Kng (envelope-from ) for ; Sun, 11 Jul 2021 05:41:35 +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 AFE8024B44 for ; Sun, 11 Jul 2021 07:41:34 +0200 (CEST) Received: from localhost ([::1]:56358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2SDd-0008Gy-DY for larch@yhetil.org; Sun, 11 Jul 2021 01:41:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2SCe-0008Fj-80 for emacs-orgmode@gnu.org; Sun, 11 Jul 2021 01:40:33 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:44958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m2SCa-0006fX-Fo for emacs-orgmode@gnu.org; Sun, 11 Jul 2021 01:40:31 -0400 Received: by mail-lf1-x134.google.com with SMTP id c28so33489184lfp.11 for ; Sat, 10 Jul 2021 22:40:26 -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=xahUoXpa5Om+zZONbVEx+ff6pORx6aJuZWsaK+tEE/U=; b=rF2X9oLOQ/JsUPSNNwQQTOG6XE+pLxM84++oBbyn6lL4rhG41uUcXiE/tJlCjdhCYY P8saIFyEPdCLpWpZAJW2TrNbhHl3i3DDEclz/aEiHUdSRVlVEeYUwaL5hGxqHS60cw/7 pGFmox3mouF6MKs6RTWlDJhsjFnVyn1emFMFmKAdlg1ElDs7bjUUcrfSJmP0OHVxz0jU FfasxNxNbL6WLalOiNAEIjbE4DNsmfcqu4uWAKcwfwRJTetcYqzx7j6pT6G/WHfjDicW 2J56OjBa63Qf6mmOEh8O75f00+WKr7IkkkUECmBQXP+AuQ9Zr+u8ezHz6z6Dfpl26pug 5ShA== 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=xahUoXpa5Om+zZONbVEx+ff6pORx6aJuZWsaK+tEE/U=; b=heCHFgACqoR74jcgwxuboJdZwVbP6LPgakSZubkM+D9nuYdfnvsx6okUTvrnCEXh5l Rxjhm9NVNjsZRo2LJN3P8IYir0jhaOq8/56MjlUfLcd+k/XqLBSB4PucwXbbk2laHgal GXRkpRhl5b3mA1w9GD5OYTF1iNQpgnzgWHpcU85VpT4SvlJ0VJ10XXpQ9nQWf8zKQP15 og41UA9GXRCuZbVjN8pxEinXc4H+zRmAn3Ybk3okDcBwETgmS7XRgneaXaJiWZgeqxlH tMBgMm33kAeqL0Gfst/kOEzwSKRK4iL4THxGFXavPk9noBTLj+fCXs7vQtIhe+Hoj5BG ucFg== X-Gm-Message-State: AOAM531TRKen/HJEhjfHaP4iaWJ6WXQEw0zVxotp1UydWPoUU3P/x77U CjSwbdZqIMF1FOL9eYteDTE= X-Google-Smtp-Source: ABdhPJwUVf58g2obPpSWXxe/5qKHUl8U5Rgj4WDw4aqY3BxHFa2Z+wZJl12V4C6IKanOih7JagxSng== X-Received: by 2002:a19:6e0d:: with SMTP id j13mr14631843lfc.108.1625982024499; Sat, 10 Jul 2021 22:40:24 -0700 (PDT) Received: from localhost ([158.255.2.9]) by smtp.gmail.com with ESMTPSA id a10sm584662lfb.93.2021.07.10.22.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 22:40:23 -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: <874kd1wsc6.fsf@localhost> References: <877diwbm6a.fsf@gmail.com> <87a6muwa93.fsf@localhost> <874kd1wsc6.fsf@localhost> Date: Sun, 11 Jul 2021 13:40:26 +0800 Message-ID: <871r85wgqd.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=yantar92@gmail.com; helo=mail-lf1-x134.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=1625982094; 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=K6haBiUMIQidH5wtJ2QjrlREra8XXzK2EtCH/a9Vu60=; b=g+eCCFkjG8kLHtUtkiBPjsAhHe1ZS2bofnLFHKkElWzmNu9ngkGQRaj5NcV9TxhChvxQfE y2OYuSL0plOIXCvvbK6bXE62c1qN8ALhmJ7Rx5bk2+/w2bo3XI+LxpBzWfPiXBSgAiOYPn Bb8x4jWA8YrZsgXrGr1Sb5PNa4GhBKEe54m3+A6982Z3V1wuoqfKjhRygctOfiV9BCLHq2 VnM/qE6YYu73xV8tD4QjoV4z3BX39yikDW+8sNhtROXiy2Bobjc1oYJt+LzF9ZMjyza4KO VXQ2h3X3txyN+BlXI5ZiyRQ1UUDec5LhGRsuV7n0jTSccPN7vcDbh/kMCjJlnA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625982094; a=rsa-sha256; cv=none; b=hbOK/Qja0yp/pgtXCDC5qAI3aEHYC8yKMnxJUrDDH/wsCqSfFGGRGBN+RKeTCPbSEygSS3 4EPQsh74PGKN4AiVtV9KcbPuzwTnEDeGpjHi3kh8rA2SrRt7mijsq9xML8FQL8kb7wEkBb 2XZ/6D9DDa8XFDRis2RNyCx0dIGaw5FHrWbB6QF+4/8pLB9lReHu/ekzmfG4FC5oM1sqkz 4bggc6IxmnfNln7A4frNIqrkRG270TmzjFUhKcWOJQVEp2XIeNoxHeTaeMAcz3yY+xdDWi pA3/0aMkRh4/CIBlxhAbrPUVpSnnE/CotqTNTRzJgNuuJSXhez4Kj+JzI2eE/A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=rF2X9oLO; 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=rF2X9oLO; 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: AFE8024B44 X-Spam-Score: 0.79 X-Migadu-Scanner: scn1.migadu.com X-TUID: syILf1foFYfN --=-=-= Content-Type: text/plain Updating the patch with relevant new test --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-duplicate-logbook-entry-for-repeated-tasks.patch >From 5b89c95318a38df9f0a6706b6eb5320baafbd4d8 Mon Sep 17 00:00:00 2001 Message-Id: <5b89c95318a38df9f0a6706b6eb5320baafbd4d8.1625981997.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 | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 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..0634ba608 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -7397,6 +7397,27 @@ (ert-deftest test-org/auto-repeat-maybe () CLOCK: [2012-03-29 Thu 10:00]--[2012-03-29 Thu 16:40] => 6:40" (org-todo "DONE") (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 --=-=-=--