diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2009-06-02 17:01:11 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2009-06-02 17:01:11 +0200 |
commit | a5dc9456ddfe94554996eefdaf01402800a96b67 (patch) | |
tree | 32be5c46db0f3b44139e627f7c867352ccca773d | |
parent | 8a2247454c6464b634138c0fa04d268e1247757b (diff) | |
download | org-mode-a5dc9456ddfe94554996eefdaf01402800a96b67.tar.gz |
New option `org-clock-out-switch-to-state'.
Can be used to change the TODO state when clocking out.
-rwxr-xr-x | lisp/ChangeLog | 3 | ||||
-rw-r--r-- | lisp/org-clock.el | 30 |
2 files changed, 32 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5adf598..a97d7ea 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2009-06-02 Carsten Dominik <carsten.dominik@gmail.com> + * org-clock.el (org-clock-out-switch-to-state): New option. + (org-clock-out): Honor `org-clock-out-switch-to-state'. + * org-compat.el (org-compatible-face): Improve macro. * org.el (org-global-properties-fixed): Add default for diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 6cc148c..cacfd83 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -86,6 +86,19 @@ state to switch it to." (string :tag "State") (symbol :tag "Function"))) +(defcustom org-clock-out-switch-to-state nil + "Set task to a special todo state after clocking out. +The value should be the state to which the entry should be +switched. If the value is a function, it must take one +parameter (the current TODO state of the item) and return the +state to switch it to." + :group 'org-clock + :group 'org-todo + :type '(choice + (const :tag "Don't force a state" nil) + (string :tag "State") + (symbol :tag "Function"))) + (defcustom org-clock-history-length 5 "Number of clock tasks to remember in history." :group 'org-clock @@ -541,7 +554,7 @@ decides which time to use." ((or (equal cmt "all") (and (or (not cmt) (equal cmt "auto")) (not lr))) - (setq msg-extra "Showing all task time.") + (setq msg-extra "Showing entire task time.") nil) ((or (equal cmt "repeat") (and (or (not cmt) (equal cmt "auto")) @@ -680,6 +693,21 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (setq org-clock-mode-line-timer nil)) (setq global-mode-string (delq 'org-mode-line-string global-mode-string)) + (when org-clock-out-switch-to-state + (save-excursion + (org-back-to-heading t) + (let ((org-inhibit-logging t)) + (cond + ((functionp org-clock-out-switch-to-state) + (looking-at org-complex-heading-regexp) + (let ((newstate (funcall org-clock-out-switch-to-state + (match-string 2)))) + (if newstate (org-todo newstate)))) + ((and org-clock-out-switch-to-state + (not (looking-at (concat outline-regexp "[ \t]*" + org-clock-out-switch-to-state + "\\>")))) + (org-todo org-clock-out-switch-to-state)))))) (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" ""))))))) |