diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2010-02-20 16:14:10 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2010-02-20 16:14:32 +0100 |
commit | 73f85e8b659650573c84588d8264d0f7ffbbe810 (patch) | |
tree | f93867d6ea369f97701f0f6d707f692f730553c1 | |
parent | 829ed41161ed3e2f04915dd32a4beb88f1f9cfb9 (diff) | |
download | org-mode-73f85e8b659650573c84588d8264d0f7ffbbe810.tar.gz |
Add some hooks to org-timer.el
Patch by Austin Frank.
-rwxr-xr-x | lisp/ChangeLog | 10 | ||||
-rw-r--r-- | lisp/org-timer.el | 28 |
2 files changed, 35 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4fa57b3..9cc80e4 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2010-02-20 Carsten Dominik <carsten.dominik@gmail.com> + + * org-timer.el (org-timer-start-hook, org-timer-stop-hook) + (org-timer-pause-hook, org-timer-set-hook) + (org-timer-cancel-hook): New hooks. + (org-timer-start): Run `org-timer-start-hook'. + (org-timer-pause-or-continue): Run `org-timer-pause-hook'. + (org-timer-stop): Run `org-timer-stop-hook'. + (org-timer-cancel-timers): Run `org-timer-cancel-hook'. + 2010-02-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-reveal): Double prefix arg shows the subtree of the diff --git a/lisp/org-timer.el b/lisp/org-timer.el index ed5a423..f81014c 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -48,6 +48,21 @@ the value of the relative timer." :group 'org-time :type 'string) +(defvar org-timer-start-hook nil + "Hook run after relative timer is started.") + +(defvar org-timer-stop-hook nil + "Hook run before relative timer is stopped.") + +(defvar org-timer-pause-hook nil + "Hook run before relative timer is paused.") + +(defvar org-timer-set-hook nil + "Hook run after countdown timer is set.") + +(defvar org-timer-cancel-hook nil + "Hook run before countdown timer is canceled.") + ;;;###autoload (defun org-timer-start (&optional offset) "Set the starting time for the relative timer to now. @@ -82,7 +97,8 @@ the region 0:00:00." (org-timer-set-mode-line 'on) (message "Timer start time set to %s, current value is %s" (format-time-string "%T" org-timer-start-time) - (org-timer-secs-to-hms (or delta 0)))))) + (org-timer-secs-to-hms (or delta 0))) + (run-hooks 'org-timer-start-hook)))) (defun org-timer-pause-or-continue (&optional stop) "Pause or continue the relative timer. With prefix arg, stop it entirely." @@ -103,6 +119,7 @@ the region 0:00:00." (message "Timer continues at %s" (org-timer-value-string))) (t ;; pause timer + (run-hooks 'org-timer-pause-hook) (setq org-timer-pause-time (current-time)) (org-timer-set-mode-line 'pause) (message "Timer paused at %s" (org-timer-value-string))))) @@ -110,6 +127,7 @@ the region 0:00:00." (defun org-timer-stop () "Stop the relative timer." (interactive) + (run-hooks 'org-timer-stop-hook) (setq org-timer-start-time nil org-timer-pause-time nil) (org-timer-set-mode-line 'off)) @@ -264,6 +282,7 @@ VALUE can be `on', `off', or `pause'." (interactive) (mapc (lambda(timer) (when (eval timer) + (run-hooks 'org-timer-cancel-hook) (cancel-timer timer) (setq timer nil))) '(org-timer-timer1 @@ -316,8 +335,11 @@ VALUE can be `on', `off', or `pause'." (setq timer-set t) (setq org-timer-last-timer (run-with-timer - secs nil 'org-notify (format "%s: time out" hl) t)) - (set timer org-timer-last-timer))) + secs nil 'org-notify (format "%s: time out" hl) t)) +; (setq org-timer-mode-line-timer +; (run-with-timer 1 1 'org-timer-update-mode-line)) + (set timer org-timer-last-timer) + (run-hooks 'org-timer-set-hook))) '(org-timer-timer1 org-timer-timer2 org-timer-timer3))))) |