emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix broken one-time continuous clock-in
@ 2018-01-08 14:36 Aliaksey Artamonau
  2018-01-10 11:55 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Aliaksey Artamonau @ 2018-01-08 14:36 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

Hi,

I noticed that when I try using C-u C-u C-u `org-clock-in', I get two clocks started: one using last clock out time, and one using current time. Clocking out then closes the last one and leaves the former one dangling. This doesn't happen though when I have `org-clock-continuously' simply set to `t' and use `org-clock-in' without any prefix. So I started looking what the cause was. When triple-prefix is used, `org-clock-in' binds `org-clock-continuously' to `t' temporarily and calls itself recursively. But then it continues the execution normally once the recursive call returns. And that's what seemingly breaks things. The attached patch addresses the issue by aborting after the recursive call is over. That seemed like the easiest way to address the issue, but if it's not in the "spirit" o
 f org-mode, I'll be happy to work on improving the patch.


Thanks,
Aliaksey


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-clock.el-Fix-one-time-continuous-clock-in.patch --]
[-- Type: text/x-patch, Size: 1241 bytes --]

From 9aa5fb535b54df5a35c26d89f3e9ddb0e335def0 Mon Sep 17 00:00:00 2001
From: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Date: Mon, 8 Jan 2018 16:53:20 +0300
Subject: [PATCH] org-clock.el: Fix one time continuous clock in

* org-clock.el (org-clock-in): Abort after calling `org-clock-in'
  recursively with `org-clock-continuously' set.

Without the change the recursive call to `org-clock-in' would
insert a clock of last clock-out, but then the original call
would continue by inserting another clock at
current-time. As a result of that, clocking out uses the latter
of the two clocks and leaves the other one dangling.

TINYCHANGE
---
 lisp/org-clock.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 370473017..010304484 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1235,7 +1235,8 @@ the default behavior."
       (when (equal select '(64))
 	;; Set start-time to `org-clock-out-time'
 	(let ((org-clock-continuously t))
-	  (org-clock-in nil org-clock-out-time)))
+	  (org-clock-in nil org-clock-out-time)
+	  (throw 'abort nil)))
 
       (when (equal select '(4))
 	(setq selected-task (org-clock-select-task "Clock-in on task: "))
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix broken one-time continuous clock-in
  2018-01-08 14:36 [PATCH] Fix broken one-time continuous clock-in Aliaksey Artamonau
@ 2018-01-10 11:55 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2018-01-10 11:55 UTC (permalink / raw)
  To: Aliaksey Artamonau; +Cc: emacs-orgmode

Hello,

Aliaksey Artamonau <aliaksiej.artamonau@gmail.com> writes:

> I noticed that when I try using C-u C-u C-u `org-clock-in', I get two
> clocks started: one using last clock out time, and one using current
> time. Clocking out then closes the last one and leaves the former one
> dangling. This doesn't happen though when I have
> `org-clock-continuously' simply set to `t' and use `org-clock-in'
> without any prefix. So I started looking what the cause was. When
> triple-prefix is used, `org-clock-in' binds `org-clock-continuously'
> to `t' temporarily and calls itself recursively. But then it continues
> the execution normally once the recursive call returns. And that's
> what seemingly breaks things. The attached patch addresses the issue
> by aborting after the recursive call is over. That seemed like the
> easiest way to address the issue, but if it's not in the "spirit" o
>  f org-mode, I'll be happy to work on improving the patch.

Applied. Thank you!

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-10 11:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-08 14:36 [PATCH] Fix broken one-time continuous clock-in Aliaksey Artamonau
2018-01-10 11:55 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).