Download
(defconst work-timer-version "0.3")
(defgroup work-timer '()
"A simple package to help deal with procrastination.
This package makes use of the (10+2)*5 procrastination hack by
Merlin Mann. Essentially you work for 10 minutes on a task, then
you switch to 2 minutes of procrastination, with the idea that by
having a scheduled procrastination time, you will be lass likely
to actually procrastinate.
For a more detailed explination see:
http://www.43folders.com/2005/10/11/procrastination-hack-1025")
(defcustom work-timer-working-time 10
"Time fragment that you should spend working (in minutes)."
:type 'float
:group 'work-timer)
(defcustom work-timer-relax-time 2
"Time fragment that you should spend relaxing (in minutes)."
:type 'float
:group 'work-timer)
(defcustom work-timer-work-hook nil
"Hook that is run when it is time to work."
:type 'hook
:group 'work-timer)
(defcustom work-timer-relax-hook nil
"Hook that is run when it is time to relax."
:type 'hook
:group 'work-timer)
(defvar work-timer-timer nil
"Actual timer for work-timer.")
(defvar work-timer-state 'not-started
"Shows the actual state of the worktimer.
Can be one of the following symbols:
not-started
work-time
relax-time")
(defun work-timer--relax ()
"Internal function to set the timer mode to relax."
(when (timerp work-timer-timer)
(cancel-timer work-timer-timer))
(setq work-timer-state 'relax-time)
(run-hooks 'work-timer-relax-hook)
(todochiku-message "Work Timer" "Time to chill." (todochiku-icon 'star))
(setq work-timer-timer (run-with-timer (* 60 work-timer-relax-time) nil 'work-timer--work)))
(defun work-timer--work ()
"Internal function to set the timer mode to work."
(when (timerp work-timer-timer)
(cancel-timer work-timer-timer))
(setq work-timer-state 'work-time)
(run-hooks 'work-timer-work-hook)
(todochiku-message "Work Timer" "Time to work." (todochiku-icon 'alarm))
(setq work-timer-work (run-with-timer (* 60 work-timer-working-time) nil 'work-timer--relax)))
(defun work-timer-start ()
"Start the work timer.
This will call todochiku to tell you to work, and then run `work-timer-work-hook'."
(interactive)
(work-timer--work)
"Work Timer Started")
(defun work-timer-stop ()
"Stop the work timer.
This will call todochiku to tell you to chill the heck out, and run
`work-timer-relax-hook'."
(interactive)
(when (not (null work-timer-timer))
(cancel-timer work-timer-timer))
(todochiku-message "Work Timer" "Work Timer Cancelled." (todochiku-icon 'alert))
(setq work-timer-state 'not-started)
"Work Timer Cancelled.")
(defun work-timer-reset ()
"Reset the work timer in relax mode."
(interactive)
(work-timer--relax)
"Reset to Relax Mode")
(defun work-timer-reset-work ()
"Reset the work timer in work mode."
(interactive)
(work-timer--work)
"Reset to Work Mode")
(when nil
"Testing"
(progn
"Setup for easy testing."
(setq todochiku-message-too t)
(setq work-timer-working-time 0.0625)
(setq work-timer-relax-time 0.125))
(work-timer-start)
(progn
"Undo testing."
(setq todochiku-message-too nil)
(setq work-timer-working-time 10)
(setq work-timer-relax-time 2)
(work-timer-stop))
)
(provide 'work-timer)