* [PATCH] Fix for bug that makes the user have to answer the prompt more than once for resolving running clock after being idle
@ 2022-03-17 11:22 Ignacio Casso
2022-10-16 5:22 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Ignacio Casso @ 2022-03-17 11:22 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 381 bytes --]
Hello,
I have fixed the bug reported in
https://lists.gnu.org/archive/html/emacs-orgmode/2010-08/msg00188.html,
https://lists.gnu.org/archive/html/emacs-orgmode/2019-02/msg00333.html,
and
https://lists.gnu.org/archive/html/emacs-orgmode/2022-03/msg00127.html.
In the last of those threads (two emails) I explained in detail the bug and the
reason it happens. Here is the patch:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Bug fix --]
[-- Type: text/x-diff, Size: 2077 bytes --]
From bb4c9e0836b039a496a033a002d97d7062bd8dc8 Mon Sep 17 00:00:00 2001
From: Ignacio <ignaciocasso@hotmail.org>
Date: Thu, 17 Mar 2022 11:50:44 +0100
Subject: [PATCH] org-clock.el: resolve running clock after being idle only
once
* lisp/org-clock.el (org-resolve-clocks-if-idle): Cancel timer
for `org-resolve-clocks-if-idle' while `org-clock-resolve' waits for
the user to answer the prompt.
After the user answered the prompt to resolve the running clock, the
pending scheduled calls to `org-resolve-clocks-if-idle' (one for each
minute it took the user to answer) were being executed immediately.
But after an old change in Emacs, the user answer does not reset the
idle timer anymore, so each of those calls thought that the user was
still idle and prompted them again, to the user had to answer the same
prompt again N times. This commit fixes that bug.
TINYCHANGE
---
lisp/org-clock.el | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 6f441c18e..83e6dd319 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1231,7 +1231,9 @@ so long."
(org-clock-user-idle-start
(time-since org-clock-user-idle-seconds))
(org-clock-resolving-clocks-due-to-idleness t))
- (if (> org-clock-user-idle-seconds (* 60 org-clock-idle-time))
+ (when (> org-clock-user-idle-seconds (* 60 org-clock-idle-time))
+ (cancel-timer org-clock-idle-timer)
+ (setq org-clock-idle-timer nil)
(org-clock-resolve
(cons org-clock-marker
org-clock-start-time)
@@ -1240,7 +1242,10 @@ so long."
(/ (float-time
(time-since org-clock-user-idle-start))
60)))
- org-clock-user-idle-start)))))
+ org-clock-user-idle-start)
+ (when (and (org-clocking-p) (not org-clock-idle-timer))
+ (setq org-clock-idle-timer
+ (run-with-timer 60 60 #'org-resolve-clocks-if-idle)))))))
(defvar org-clock-current-task nil "Task currently clocked in.")
(defvar org-clock-out-time nil) ; store the time of the last clock-out
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix for bug that makes the user have to answer the prompt more than once for resolving running clock after being idle
2022-03-17 11:22 [PATCH] Fix for bug that makes the user have to answer the prompt more than once for resolving running clock after being idle Ignacio Casso
@ 2022-10-16 5:22 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-10-16 5:22 UTC (permalink / raw)
To: Ignacio Casso; +Cc: emacs-orgmode
Ignacio Casso <ignaciocasso@hotmail.com> writes:
> I have fixed the bug reported in
> https://lists.gnu.org/archive/html/emacs-orgmode/2010-08/msg00188.html,
> https://lists.gnu.org/archive/html/emacs-orgmode/2019-02/msg00333.html,
> and
> https://lists.gnu.org/archive/html/emacs-orgmode/2022-03/msg00127.html.
>
> In the last of those threads (two emails) I explained in detail the bug and the
> reason it happens. Here is the patch:
>
> From bb4c9e0836b039a496a033a002d97d7062bd8dc8 Mon Sep 17 00:00:00 2001
> From: Ignacio <ignaciocasso@hotmail.org>
> Date: Thu, 17 Mar 2022 11:50:44 +0100
> Subject: [PATCH] org-clock.el: resolve running clock after being idle only
> once
Thanks!
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=31f2510995c938d96947086ecd807d9b148ec7f8
--
Ihor Radchenko // yantar92,
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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-16 5:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-17 11:22 [PATCH] Fix for bug that makes the user have to answer the prompt more than once for resolving running clock after being idle Ignacio Casso
2022-10-16 5:22 ` Ihor Radchenko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.