emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix broken one-time continuous clock-in
Date: Mon, 08 Jan 2018 17:36:48 +0300	[thread overview]
Message-ID: <87incca03j.fsf@gmail.com> (raw)

[-- 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


             reply	other threads:[~2018-01-08 14:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-08 14:36 Aliaksey Artamonau [this message]
2018-01-10 11:55 ` [PATCH] Fix broken one-time continuous clock-in Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87incca03j.fsf@gmail.com \
    --to=aliaksiej.artamonau@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).