[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Re: Bug: Duplicate logbook entry for repeated tasks [9.4.6 (
From: |
Ihor Radchenko |
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/)] |
Date: |
Sun, 11 Jul 2021 13:57:39 +0800 |
And yet another update fixing a typo in previous patch. Sorry
>From 89a60d654663b68f1c149fb3341a50191027f45e Mon Sep 17 00:00:00 2001
Message-Id:
<89a60d654663b68f1c149fb3341a50191027f45e.1625983004.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
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
- [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/)], Ihor Radchenko, 2021/07/10
- 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/)], Gustavo Barros, 2021/07/10
- 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/)], Bhavin Gandhi, 2021/07/10
- 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/)], Ihor Radchenko, 2021/07/10
- 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/)], Ihor Radchenko, 2021/07/11
- 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/)],
Ihor Radchenko <=
- 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/)], Bhavin Gandhi, 2021/07/12
- Re: [PATCH] Bug: Duplicate logbook entry for repeated tasks [9.4.6 (9.4.6-gab9f2a @ /home/gustavo/.emacs.d/elpa/org-9.4.6/)], Carlo Tambuatco, 2021/07/12
- Re: [PATCH] Bug: Duplicate logbook entry for repeated tasks [9.4.6 (9.4.6-gab9f2a @ /home/gustavo/.emacs.d/elpa/org-9.4.6/)], Alan Ristow, 2021/07/13
- Re: [PATCH] Bug: Duplicate logbook entry for repeated tasks [9.4.6 (9.4.6-gab9f2a @ /home/gustavo/.emacs.d/elpa/org-9.4.6/)], Bhavin Gandhi, 2021/07/13
- Re: [PATCH] Bug: Duplicate logbook entry for repeated tasks [9.4.6 (9.4.6-gab9f2a @ /home/gustavo/.emacs.d/elpa/org-9.4.6/)], Ihor Radchenko, 2021/07/17
- 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/)], Ihor Radchenko, 2021/07/17