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] Set org-clock-clocking-in when calling org-clock-out from org-clock-in
Date: Thu, 20 May 2010 12:20:20 -0400	[thread overview]
Message-ID: <1274372420-6164-1-git-send-email-bernt@norang.ca> (raw)
In-Reply-To: <871vd64m0q.fsf@gollum.intra.norang.ca>

org-clock-out-hook can now query org-clock-clocking-in to see if org-clock-out is
being called inside org-clock-in.  This allows the hook to selectively clock
in another task without leaving clocks open.
---
Here's the updated patch which seems to work just as well.

This patch is available at git://git.norang.ca/org-mode.git persistent-clocking

Most of the changes here are whitespace.  The very last change in the patch is the 
only interesting part.

-Bernt

 lisp/org-clock.el |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 68a40ce..dbcd032 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -925,7 +925,7 @@ the clocking selection, associated with the letter `d'."
 			     (org-clocking-p)))
 	  ts selected-task target-pos (msg-extra "")
 	  (leftover (and (not org-clock-resolving-clocks)
-			  org-clock-leftover-time)))
+			 org-clock-leftover-time)))
       (when (and org-clock-auto-clock-resolution
 		 (or (not interrupting)
 		     (eq t org-clock-auto-clock-resolution))
@@ -944,22 +944,23 @@ the clocking selection, associated with the letter `d'."
 	;; Save a marker to this task, so that we can go back.
 	;; First check if we are trying to clock into the same task!
 	(if (save-excursion
-		(unless selected-task
-		  (org-back-to-heading t))
-		(and (equal (marker-buffer org-clock-hd-marker)
-			    (if selected-task
-				(marker-buffer selected-task)
-			      (current-buffer)))
-		     (= (marker-position org-clock-hd-marker)
-			(if selected-task
-			    (marker-position selected-task)
-			  (point)))))
+	      (unless selected-task
+		(org-back-to-heading t))
+	      (and (equal (marker-buffer org-clock-hd-marker)
+			  (if selected-task
+			      (marker-buffer selected-task)
+			    (current-buffer)))
+		   (= (marker-position org-clock-hd-marker)
+		      (if selected-task
+			  (marker-position selected-task)
+			(point)))))
 	    (message "Clock continues in \"%s\"" org-clock-heading)
 	  (progn
 	    (move-marker org-clock-interrupted-task
 			 (marker-position org-clock-marker)
 			 (org-clocking-buffer))
-	    (org-clock-out t))))
+	    (let ((org-clock-clocking-in t))
+	      (org-clock-out t)))))
 
       (when (equal select '(16))
 	;; Mark as default clocking task
-- 
1.7.1.86.g0e460

  reply	other threads:[~2010-05-20 16:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-20 15:14 [PATCH] Add org-clock-clocking-in for hooks Bernt Hansen
2010-05-20 15:43 ` Bernt Hansen
2010-05-20 16:20   ` Bernt Hansen [this message]
2010-05-20 21:23     ` [PATCH] Set org-clock-clocking-in when calling org-clock-out from org-clock-in John Wiegley

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=1274372420-6164-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).