emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bernt Hansen <bernt@norang.ca>
To: emacs-orgmode@gnu.org
Cc: Bernt Hansen <bernt@norang.ca>
Subject: [PATCH] Fix J in agenda when clock out hook clocks in again
Date: Thu,  9 Feb 2012 12:43:40 -0500	[thread overview]
Message-ID: <1328809420-31933-1-git-send-email-bernt@norang.ca> (raw)

* org-clock.el (org-clock-out): Do not delete the current clocking task
when org-clock-out-hook clocks in another task

My clock out hook keeps the clock running by automatically clocking in
a new task (the parent task, or the default task).  This sets a new
clocking task which was then clobbered at the end of org-clock-out
so that J in the agenda would return

    "No running clock, use `C-c C-x C-j' to jump to the most recent one"

We now detect that another task is clocked in and skip clearing the
org-clock-current-task variable used by the agenda to determine if
the clock is currently running.
---
 lisp/org-clock.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index a1df776..7dff094 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1387,7 +1387,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
 	  (message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m
 		   (if remove " => LINE REMOVED" ""))
           (run-hooks 'org-clock-out-hook)
-	  (org-clock-delete-current))))))
+	  (unless (org-clocking-p)
+	    (org-clock-delete-current)))))))
 
 (add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer)
 
-- 
1.7.9.48.g85da4d

             reply	other threads:[~2012-02-09 17:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09 17:43 Bernt Hansen [this message]
2012-02-12 18:48 ` [Accepted] Fix J in agenda when clock out hook clocks in again David Maus

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=1328809420-31933-1-git-send-email-bernt@norang.ca \
    --to=bernt@norang.ca \
    --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).