From 30ffaca5aa2cbffbfa2dd21335c058c75a22ed33 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 24 Feb 2010 16:28:43 +0100 Subject: [PATCH] Added org-clock-current-task which stores the last clocked in entry. The `org-clock-set-current' and `org-clock-delete-current' functions handle this variable. The variable only stores the last clocked in entry, not the history of clocked in tasks. --- lisp/ChangeLog | 6 ++++++ lisp/org-clock.el | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 20cb4d06a..8c683ed47 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2010-02-24 Bastien Guerry + + * org-clock.el (org-clock-current-task): New variable to store + last clocked in task. + (org-clock-set-current, org-clock-delete-current): New functions. + 2010-02-24 Carsten Dominik * org-remember.el (org-remember-apply-template): Extend comment. diff --git a/lisp/org-clock.el b/lisp/org-clock.el index e3866be15..cb378e62c 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."