emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [org-timer] PATCH add hooks to org-timer.el
@ 2010-02-20 13:41 Austin Frank
  2010-02-20 14:35 ` Carsten Dominik
  2010-04-15  7:52 ` Emmanuel Di Pretoro
  0 siblings, 2 replies; 4+ messages in thread
From: Austin Frank @ 2010-02-20 13:41 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 433 bytes --]

Hello all--

I'm experimenting with the pomodoro technique [1] and trying to
integrate it with org mode.  I've attached a patch that defines some
hooks for org-timer.el.  My intention is to use these hooks to automate
record keeping and interactions with org-clock.

If this isn't the correct approach to adding hooks to timer functions,
what would you suggest?

Thanks for considering it,
/au

[1] http://www.pomodorotechnique.com


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-add-hooks-for-relative-and-countdown-timers.patch --]
[-- Type: text/x-patch, Size: 3136 bytes --]

From 86de94d18302bda17379c35f11423788b11348c2 Mon Sep 17 00:00:00 2001
From: Austin F. Frank <austin.frank@gmail.com>
Date: Sat, 20 Feb 2010 08:22:47 -0500
Subject: [PATCH 3/3] add hooks for relative and countdown timers

---
 lisp/org-timer.el |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index ed5a423..47397aa 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -48,6 +48,31 @@ the value of the relative timer."
   :group 'org-time
   :type 'string)
 
+(defcustom org-timer-start-hook nil
+  "Hook run after relative timer is started."
+  :group 'org-time
+  :type 'hook)
+
+(defvar org-timer-stop-hook nil
+  "Hook run before relative timer is stopped."
+  :group 'org-time
+  :type 'hook)
+
+(defvar org-timer-pause-hook nil
+  "Hook run before relative timer is paused."
+  :group 'org-time
+  :type 'hook)
+
+(defvar org-timer-set-hook nil
+  "Hook run after countdown timer is set."
+  :group 'org-time
+  :type 'hook)
+
+(defvar org-timer-cancel-hook nil
+  "Hook run before countdown timer is canceled."
+  :group 'org-time
+  :type 'hook)
+
 ;;;###autoload
 (defun org-timer-start (&optional offset)
   "Set the starting time for the relative timer to now.
@@ -82,7 +107,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."
@@ -102,6 +128,7 @@ the region 0:00:00."
     (org-timer-set-mode-line 'on)
     (message "Timer continues at %s" (org-timer-value-string)))
    (t
+    (run-hooks 'org-timer-pause-hook)
     ;; pause timer
     (setq org-timer-pause-time (current-time))
     (org-timer-set-mode-line 'pause)
@@ -110,6 +137,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 +292,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
@@ -317,7 +346,10 @@ VALUE can be `on', `off', or `pause'."
 		  (setq org-timer-last-timer
 			(run-with-timer
 			secs nil 'org-notify (format "%s: time out" hl) t))
-		  (set timer org-timer-last-timer)))
+                  (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)))))
-- 
1.7.0


[-- Attachment #1.1.3: Type: text/plain, Size: 101 bytes --]


-- 
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc

[-- Attachment #1.2: Type: application/pgp-signature, Size: 194 bytes --]

[-- Attachment #2: 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [org-timer] PATCH add hooks to org-timer.el
  2010-02-20 13:41 [org-timer] PATCH add hooks to org-timer.el Austin Frank
@ 2010-02-20 14:35 ` Carsten Dominik
  2010-02-20 15:02   ` Austin Frank
  2010-04-15  7:52 ` Emmanuel Di Pretoro
  1 sibling, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2010-02-20 14:35 UTC (permalink / raw)
  To: Austin Frank; +Cc: emacs-orgmode

Hi Austin,

I have applied most of the patch, but I have a question:

> @@ -317,7 +346,10 @@ VALUE can be `on', `off', or `pause'."
> 		  (setq org-timer-last-timer
> 			(run-with-timer
> 			secs nil 'org-notify (format "%s: time out" hl) t))
> -		  (set timer org-timer-last-timer)))
> +                  (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)))))

Could you please coment on the above section?  What exactly is it  
doing and why?

- Carsten

On Feb 20, 2010, at 2:41 PM, Austin Frank wrote:

> Hello all--
>
> I'm experimenting with the pomodoro technique [1] and trying to
> integrate it with org mode.  I've attached a patch that defines some
> hooks for org-timer.el.  My intention is to use these hooks to  
> automate
> record keeping and interactions with org-clock.
>
> If this isn't the correct approach to adding hooks to timer functions,
> what would you suggest?
>
> Thanks for considering it,
> /au
>
> [1] http://www.pomodorotechnique.com
>
> From 86de94d18302bda17379c35f11423788b11348c2 Mon Sep 17 00:00:00 2001
> From: Austin F. Frank <austin.frank@gmail.com>
> Date: Sat, 20 Feb 2010 08:22:47 -0500
> Subject: [PATCH 3/3] add hooks for relative and countdown timers
>
> ---
> lisp/org-timer.el |   36 ++++++++++++++++++++++++++++++++++--
> 1 files changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/org-timer.el b/lisp/org-timer.el
> index ed5a423..47397aa 100644
> --- a/lisp/org-timer.el
> +++ b/lisp/org-timer.el
> @@ -48,6 +48,31 @@ the value of the relative timer."
>   :group 'org-time
>   :type 'string)
>
> +(defcustom org-timer-start-hook nil
> +  "Hook run after relative timer is started."
> +  :group 'org-time
> +  :type 'hook)
> +
> +(defvar org-timer-stop-hook nil
> +  "Hook run before relative timer is stopped."
> +  :group 'org-time
> +  :type 'hook)
> +
> +(defvar org-timer-pause-hook nil
> +  "Hook run before relative timer is paused."
> +  :group 'org-time
> +  :type 'hook)
> +
> +(defvar org-timer-set-hook nil
> +  "Hook run after countdown timer is set."
> +  :group 'org-time
> +  :type 'hook)
> +
> +(defvar org-timer-cancel-hook nil
> +  "Hook run before countdown timer is canceled."
> +  :group 'org-time
> +  :type 'hook)
> +
> ;;;###autoload
> (defun org-timer-start (&optional offset)
>   "Set the starting time for the relative timer to now.
> @@ -82,7 +107,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."
> @@ -102,6 +128,7 @@ the region 0:00:00."
>     (org-timer-set-mode-line 'on)
>     (message "Timer continues at %s" (org-timer-value-string)))
>    (t
> +    (run-hooks 'org-timer-pause-hook)
>     ;; pause timer
>     (setq org-timer-pause-time (current-time))
>     (org-timer-set-mode-line 'pause)
> @@ -110,6 +137,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 +292,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
> @@ -317,7 +346,10 @@ VALUE can be `on', `off', or `pause'."
> 		  (setq org-timer-last-timer
> 			(run-with-timer
> 			secs nil 'org-notify (format "%s: time out" hl) t))
> -		  (set timer org-timer-last-timer)))
> +                  (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)))))
> -- 
> 1.7.0
>
>
> -- 
> Austin Frank
> http://aufrank.net
> GPG Public Key (D7398C2F): http://aufrank.net/personal.asc
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [org-timer] PATCH add hooks to org-timer.el
  2010-02-20 14:35 ` Carsten Dominik
@ 2010-02-20 15:02   ` Austin Frank
  0 siblings, 0 replies; 4+ messages in thread
From: Austin Frank @ 2010-02-20 15:02 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 586 bytes --]

On Sat, Feb 20 2010, Carsten Dominik wrote:


>> @@ -317,7 +346,10 @@ VALUE can be `on', `off', or `pause'."
>> +                  (setq org-timer-mode-line-timer
>> +                        (run-with-timer 1 1 'org-timer-update-mode-
>> line))
>
> Could you please coment on the above section?  What exactly is it
> doing and why?

These two lines were left in accidentally.  This was my initial attempt
at addressing the issue I brought up in my other post about putting
countdown timers in the mode line.  It didn't work and can be removed.

A clean patch is attached.

Thanks,
/au


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-add-hooks-to-start-stop-pause-functions-for-relative.patch --]
[-- Type: text/x-patch, Size: 3031 bytes --]

From ec22f579f9c1fe3169e6103ad05d05658ab90f8e Mon Sep 17 00:00:00 2001
From: Austin F. Frank <austin.frank@gmail.com>
Date: Sat, 20 Feb 2010 09:42:48 -0500
Subject: [PATCH] add hooks to start/stop/pause functions for relative and countdown timers

---
 lisp/org-timer.el |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index ed5a423..9cee0b4 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -48,6 +48,31 @@ the value of the relative timer."
   :group 'org-time
   :type 'string)
 
+(defcustom org-timer-start-hook nil
+  "Hook run after relative timer is started."
+  :group 'org-time
+  :type 'hook)
+
+(defvar org-timer-stop-hook nil
+  "Hook run before relative timer is stopped."
+  :group 'org-time
+  :type 'hook)
+
+(defvar org-timer-pause-hook nil
+  "Hook run before relative timer is paused."
+  :group 'org-time
+  :type 'hook)
+
+(defvar org-timer-set-hook nil
+  "Hook run after countdown timer is set."
+  :group 'org-time
+  :type 'hook)
+
+(defvar org-timer-cancel-hook nil
+  "Hook run before countdown timer is canceled."
+  :group 'org-time
+  :type 'hook)
+
 ;;;###autoload
 (defun org-timer-start (&optional offset)
   "Set the starting time for the relative timer to now.
@@ -82,7 +107,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."
@@ -102,6 +128,7 @@ the region 0:00:00."
     (org-timer-set-mode-line 'on)
     (message "Timer continues at %s" (org-timer-value-string)))
    (t
+    (run-hooks 'org-timer-pause-hook)
     ;; pause timer
     (setq org-timer-pause-time (current-time))
     (org-timer-set-mode-line 'pause)
@@ -110,6 +137,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 +292,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
@@ -317,7 +346,8 @@ VALUE can be `on', `off', or `pause'."
 		  (setq org-timer-last-timer
 			(run-with-timer
 			secs nil 'org-notify (format "%s: time out" hl) t))
-		  (set timer org-timer-last-timer)))
+		  (set timer org-timer-last-timer)
+                  (run-hooks 'org-timer-set-hook)))
 	      '(org-timer-timer1
 		org-timer-timer2
 		org-timer-timer3)))))
-- 
1.7.0


[-- Attachment #1.1.3: Type: text/plain, Size: 105 bytes --]




-- 
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc

[-- Attachment #1.2: Type: application/pgp-signature, Size: 194 bytes --]

[-- Attachment #2: 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [org-timer] PATCH add hooks to org-timer.el
  2010-02-20 13:41 [org-timer] PATCH add hooks to org-timer.el Austin Frank
  2010-02-20 14:35 ` Carsten Dominik
@ 2010-04-15  7:52 ` Emmanuel Di Pretoro
  1 sibling, 0 replies; 4+ messages in thread
From: Emmanuel Di Pretoro @ 2010-04-15  7:52 UTC (permalink / raw)
  To: Austin Frank; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1119 bytes --]

Hi,

I've discovered the Pomodoro technique via the book Pomodoro Technique
Illustrated (
http://pragprog.com/titles/snfocus/pomodoro-technique-illustrated). And I'm
quite intrigued to know how you use orgmode with it.

Can you describe your use?

Thanks in advance,

Emmanuel Di Pretoro

2010/2/20 Austin Frank <austin.frank@gmail.com>

> Hello all--
>
> I'm experimenting with the pomodoro technique [1] and trying to
> integrate it with org mode.  I've attached a patch that defines some
> hooks for org-timer.el.  My intention is to use these hooks to automate
> record keeping and interactions with org-clock.
>
> If this isn't the correct approach to adding hooks to timer functions,
> what would you suggest?
>
> Thanks for considering it,
> /au
>
> [1] http://www.pomodorotechnique.com
>
>
>
> --
> Austin Frank
> http://aufrank.net
> GPG Public Key (D7398C2F): http://aufrank.net/personal.asc
>
> _______________________________________________
> 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
>
>

[-- Attachment #1.2: Type: text/html, Size: 1941 bytes --]

[-- Attachment #2: 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-15 11:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-20 13:41 [org-timer] PATCH add hooks to org-timer.el Austin Frank
2010-02-20 14:35 ` Carsten Dominik
2010-02-20 15:02   ` Austin Frank
2010-04-15  7:52 ` Emmanuel Di Pretoro

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).