johnsu01 (johnsu01) wrote,
johnsu01
johnsu01

Quick planner project timer hack

I'm going to rewrite this with a timer in the Emacs mode line, but this is a start toward what I want.

I have a lot of tasks in my Planner like:

#B _ Read -30- from 2005.05.23 {{Tasks:3847}}

These are in my personal planner, not my work one. This is because most of my work tasks are outcome-oriented, while most of my personal tasks are process-oriented. At work, I'm not really done with something until a certain goal or marker has been reached. But at home, I tend to structure my life based on the amount of time I have to invest in something. I do have certain goals in mind, like a list of books to read, but the important thing to me is that I spend a certain amount of time each day reading. I don't worry much about how many chapters I've finished.

The idea here is that when I start working on one of these daily tasks, I mark it with planner-task-in-progress. What the following piece of advice does is start a timer using the wmtimer program, in countdown mode, with the starting time set to the time in the task description. The time in the description has to be between dashes and in minutes right now. That could certainly be made more flexible, but it works for what I need.

The major limitations here are that you can't talk to wmtimer once it's running, so there is no resetting or pausing the time, or getting the current time at a stopping point to update the task description with. (Of course you can do all of this manually by using the mouse controls on the timer itself.) I think all of that will be possible when I rewrite using a timer within Emacs. For now, I've just bound C-c k to kill off the wmtimer. Stopping the timer could probably be done automatically when the task status is changed in the same way as planner-timeclock.

(defadvice planner-task-in-progress (after planner-countdown activate) "Start a project countdown timer. Use the time in minutes in the format -30- in the task description as the starting time." (let* ((description (planner-task-description (planner-current-task-info))) (task-time (and (string-match " -\\([0-9]+\\)- " description) (string-to-int (match-string 1 description)))) (countdown-time (format "00:%02d:00" task-time)) (countdown-timer (start-process-shell-command "wmtimer" nil "wmtimer" (format "-c -t %s" countdown-time)))) (global-set-key "\C-ck" `(lambda () (interactive) (kill-process ,countdown-timer)))))
Tags: code, emacs, lisp, planner
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments