emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bastienguerry@googlemail.com>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [Patch] org-clock-current-task
Date: Wed, 24 Feb 2010 15:59:23 +0100	[thread overview]
Message-ID: <87ljeiu1bo.fsf@bzg.ath.cx> (raw)
In-Reply-To: <26468BB6-A290-4344-ABB9-8DD8E876244A@gmail.com> (Carsten Dominik's message of "Wed, 24 Feb 2010 15:43:09 +0100")

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

Carsten Dominik <carsten.dominik@gmail.com> writes:

> Yes, please go ahead.

Thanks.

Attached is more complete version: now clocking out will set the 
content of `org-clock-current-task' to nil.

It occurs to me that such a simple functionnality could also use hooks.
What do you think ?  Is it better to include it in the code or to simply
put the hooks on Worg?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-clock.el.diff --]
[-- Type: text/x-diff, Size: 1627 bytes --]

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e3866be..cb378e6 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -944,6 +944,7 @@ the clocking selection, associated with the letter `d'."
 	    (org-back-to-heading t)
 	    (or interrupting (move-marker org-clock-interrupted-task nil))
 	    (org-clock-history-push)
+	    (org-clock-set-current)
 	    (cond ((functionp org-clock-in-switch-to-state)
 		   (looking-at org-complex-heading-regexp)
 		   (let ((newstate (funcall org-clock-in-switch-to-state
@@ -1042,6 +1043,15 @@ the clocking selection, associated with the letter `d'."
 	    (message "Clock starts at %s - %s" ts msg-extra)
 	    (run-hooks 'org-clock-in-hook)))))))
 
+(defvar org-clock-current-task nil
+  "Task currently clocked in.")
+(defun org-clock-set-current ()
+  "Set `org-clock-current-task' to the task currently clocked in."
+  (setq org-clock-current-task (org-get-heading)))
+(defun org-clock-delete-current ()
+  "Reset `org-clock-current-task' to nil."
+  (setq org-clock-current-task nil))
+
 (defun org-clock-mark-default-task ()
   "Mark current task as default task."
   (interactive)
@@ -1237,7 +1247,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
 	  (force-mode-line-update)
 	  (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))))))
+          (run-hooks 'org-clock-out-hook)
+	  (org-clock-delete-current))))))
 
 (defun org-clock-cancel ()
   "Cancel the running clock be removing the start timestamp."

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2010-02-24 14:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-24 14:39 [Patch] org-clock-current-task Bastien
2010-02-24 14:43 ` Carsten Dominik
2010-02-24 14:59   ` Bastien [this message]
2010-02-24 15:03     ` Carsten Dominik
2010-02-24 15:31       ` Bastien

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=87ljeiu1bo.fsf@bzg.ath.cx \
    --to=bastienguerry@googlemail.com \
    --cc=carsten.dominik@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).