[Orgmode] [Patch] org-clock-current-task

2010-02-24 Thread Bastien
This patch creates `org-clock-current-task', a new variable to access
the name of the task currently clocked in.

I use it together with erc-bot.el to let people ask me what I'm doing
right now (either from BitlBee/IRC).

Shall I push it?

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e3866be..fb6fd01 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,11 @@ 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 ()
+  (setq org-clock-current-task (org-get-heading)))
+
 (defun org-clock-mark-default-task ()
   Mark current task as default task.
   (interactive)

-- 
 Bastien
___
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


Re: [Orgmode] [Patch] org-clock-current-task

2010-02-24 Thread Carsten Dominik

Yes, please go ahead.

Thanks.

- Carsten

On Feb 24, 2010, at 3:39 PM, Bastien wrote:


This patch creates `org-clock-current-task', a new variable to access
the name of the task currently clocked in.

I use it together with erc-bot.el to let people ask me what I'm doing
right now (either from BitlBee/IRC).

Shall I push it?

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e3866be..fb6fd01 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,11 @@ 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 ()
+  (setq org-clock-current-task (org-get-heading)))
+
(defun org-clock-mark-default-task ()
  Mark current task as default task.
  (interactive)

--
Bastien
___
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


- Carsten





___
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


Re: [Orgmode] [Patch] org-clock-current-task

2010-02-24 Thread Bastien
Carsten Dominik carsten.domi...@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?

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.

-- 
 Bastien
___
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


Re: [Orgmode] [Patch] org-clock-current-task

2010-02-24 Thread Carsten Dominik
No, I think this is good to have - other functionality may want to use  
it.

Please check it in.

- Carsten

On Feb 24, 2010, at 3:59 PM, Bastien wrote:


Carsten Dominik carsten.domi...@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?

org-clock.el.diff
--
Bastien


- Carsten





___
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


Re: [Orgmode] [Patch] org-clock-current-task

2010-02-24 Thread Bastien
Carsten Dominik carsten.domi...@gmail.com writes:

 No, I think this is good to have - other functionality may want to use
 it.
 Please check it in.

Okay, done!

-- 
 Bastien


___
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