From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aliaksey Artamonau Subject: [PATCH] Fix broken one-time continuous clock-in Date: Mon, 08 Jan 2018 17:36:48 +0300 Message-ID: <87incca03j.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYYXr-0000zP-A0 for emacs-orgmode@gnu.org; Mon, 08 Jan 2018 09:37:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYYXo-0004Y8-Ih for emacs-orgmode@gnu.org; Mon, 08 Jan 2018 09:36:59 -0500 Received: from mail-lf0-x22c.google.com ([2a00:1450:4010:c07::22c]:43673) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eYYXo-0004Xk-Az for emacs-orgmode@gnu.org; Mon, 08 Jan 2018 09:36:56 -0500 Received: by mail-lf0-x22c.google.com with SMTP id z124so1894092lfd.10 for ; Mon, 08 Jan 2018 06:36:55 -0800 (PST) Received: from localhost ([93.85.82.189]) by smtp.gmail.com with ESMTPSA id m18sm2429497lje.21.2018.01.08.06.36.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jan 2018 06:36:52 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-clock.el-Fix-one-time-continuous-clock-in.patch >From 9aa5fb535b54df5a35c26d89f3e9ddb0e335def0 Mon Sep 17 00:00:00 2001 From: Aliaksey Artamonau 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 --=-=-=--