From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Moe Subject: Re: Using org-mode for recipes (i.e. cooking) Date: Thu, 24 Mar 2011 21:52:34 +0100 Message-ID: <4D8BAF12.3000904@christianmoe.com> References: Reply-To: mail@christianmoe.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090206060407050902040907" Return-path: Received: from [140.186.70.92] (port=50281 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2rTN-0001QD-Oh for emacs-orgmode@gnu.org; Thu, 24 Mar 2011 16:49:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q2rTM-0006DE-Ed for emacs-orgmode@gnu.org; Thu, 24 Mar 2011 16:49:37 -0400 Received: from mars.hitrost.net ([91.185.211.18]:38420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q2rTM-0006BI-1M for emacs-orgmode@gnu.org; Thu, 24 Mar 2011 16:49:36 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Le Wang Cc: Orgmode Mailing List This is a multi-part message in MIME format. --------------090206060407050902040907 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, On 3/24/11 12:47 PM, Le Wang wrote: (...) > Is it possible to inline count-down timers in a cooking step? For > example "2. simmer sauce for 40 minutes on low heat. > ", so there is a button at the end of the line > that starts a count-down timer. > > Many timers from different steps can be started simultaneously, and > each timer should be able to be paused and restarted. And there > should be an easy way to get an overview of of all ongoing timers from > the current document. > > Is it possible to hack this together using existing org > functionality? I don't think Org has built-in support for concurrent countdown timers. But you can fake this pretty well with org-timer, properties, column view, a dynamic block, and some lisp table formulas. A ready-to-run example is attached, hopefully self-explanatory, probably buggy, and WITH ABSOLUTELY NO WARRANTY. This is a learning exercise for me. Instead of using a start timer button (for which you could use an `elisp:' link, like the one I've put in to make it easy to stop the timer), you can write a hook to start countdowns when the TODO state changes. That rather hackish function is the only code here that's not out of the box. Yours, Christian --------------090206060407050902040907 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="recipe-timer.org" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="recipe-timer.org" #+STARTUP: showeverything #+COLUMNS: %ITEM %For %Start %Elapsed %REMAINS %Message #+TODO: TODO RUNNING | DONE Recipe with timers * First evaluate this (or put in your .emacs) #+begin_src emacs-lisp (require 'org-timer) (defun my/recipe-timer-start () "When state is changed to `RUNNING', change the `Start' property of the entry to the current value of org-timer if this is a timed recipe entry, i.e. if it has a h:m:s-formatted duration in its `For' property. When state is changed to `DONE', reset `Start' to `-'." (when (string-match org-timer-re (or (org-entry-get (point) "For") "")) (cond ((string= state "RUNNING") (org-set-property "Start" (org-timer nil t))) ((string= state "DONE") (org-set-property "Start" "-"))))) (setq org-after-todo-state-change-hook 'my/recipe-timer-start) #+end_src #+results: : my/recipe-timer-start * Recipe Here's the dynamic block with the overview. - Refresh manually with `C-c C-c' on the `begin' line. - Note that this will start the timer if it's not running. - The countdown is in the "REMAINS" column. #+begin: columnview :id local | ITEM | For | Start | Elapsed | REMAINS | Message | |-----------------------+---------+-------+---------+---------+---------| | * Recipe | | | 0:00:00 | | | | ** TODO Let simmer | 0:40:00 | - | 0:00:00 | | | | ** TODO Let ferment | 2:00:00 | - | 0:00:00 | | | | ** TODO Leave in oven | 0:04:00 | - | 0:00:00 | | | #+tblfm: $4='(org-timer nil t)::$5='(if (string-match org-timer-re $3) (org-timer-secs-to-hms (- (org-timer-hms-to-secs $2) (org-timer-hms-to-secs $4))) "")::$6='(if (< (org-timer-hms-to-secs $5) 0) "STOP!" "") #+end: Below are a few tasks with durations in their `For' properties. - Start them by changing the task's state to `RUNNING' with `C-c C-t'. (If org-timer is not running, it will be started.) - When time's up for a task, it will message `STOP!'. Navigate to the task and change its state to `DONE' with `C-c C-t' (after taking stuff out of the oven, or whatever). - When you're done, you can [[elisp:org-timer-stop][stop the timer]] (click the link or press `C-u C-c C-x ,'). ** TODO Let simmer :PROPERTIES: :For: 0:40:00 :Start: - :END: ** TODO Let ferment :PROPERTIES: :For: 2:00:00 :Start: - :END: ** TODO Leave in oven :PROPERTIES: :For: 0:04:00 :Start: - :END: --------------090206060407050902040907--