From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: Re: [org-clock] default clock for non-org-mode buffers Date: Fri, 12 Feb 2010 09:58:17 -0500 Message-ID: <87ocjusdpy.fsf@gollum.intra.norang.ca> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nfwyf-0006Iz-7i for emacs-orgmode@gnu.org; Fri, 12 Feb 2010 09:58:41 -0500 Received: from [140.186.70.92] (port=53367 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nfwye-0006In-Le for emacs-orgmode@gnu.org; Fri, 12 Feb 2010 09:58:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nfwyc-0006bF-1j for emacs-orgmode@gnu.org; Fri, 12 Feb 2010 09:58:40 -0500 Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:50714) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nfwyb-0006aD-TQ for emacs-orgmode@gnu.org; Fri, 12 Feb 2010 09:58:37 -0500 In-Reply-To: (Austin Frank's message of "Wed\, 10 Feb 2010 12\:49\:06 -0500") 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: Austin Frank Cc: emacs-orgmode@gnu.org Austin Frank writes: > Hello-- > > Sometimes I want to clock in but I'm not in an org-mode buffer. Would > it be possible to either provide a function or hook that uses the > current buffer to add a selection to the destinations provided by > `org-clock-select-task'? > > I can see two possible functions I would add to an > `org-clock-prepare-selections-hook'. First, a version with remember > that would create a new task to clock into based on the current buffer > > #v+ > (defun au-clock-in-to-new-task () > (if (fboundp org-remember) > ;; use one of my remember templates that creates a TODO entry under > ;; the heading "uncategorized tasks". it includes a link to the > ;; current buffer > (org-remember nil (kbd "t"))) > ;; > ;; then either clock in to the task right away, > ;; or add the new task to the selection buffer somehow > ;; ... > ) > #v- > > And second, a version that lets you browse to an existing task. > > #v+ > ;; I think this one doesn't work as written, but only because I don't > ;; know what I am doing > (defun au-clock-in-go-to-task () > ;; use the org-refile interface to go to an existing task > (org-refile t) > ;; > ;; then do something with link to buffer we clocked in on > ;; ... > ) > #v- > > Does a hook or some other way of introducing this functionality already > exist? If not, would other people use it? I have a couple of tasks I clock in regularly from anywhere using f9-o and f9-m (for organization and mail). These clock in the task based on ID. All of my remember buffers start the clock using the remember hooks. I - start remember - clock in via hook - enter stuff - C-c C-c - clock out via hook This remember task is now in the list. I have F11 bound to functions to make clocking in and visiting clocked items easy. HTH, Bernt ---------------------------------------------------------------------- (add-hook 'remember-mode-hook 'org-clock-in 'append) (add-hook 'org-remember-before-finalize-hook 'bh/clock-in-interrupted-task) (defun bh/clock-in-interrupted-task () "Clock in the interrupted task if there is one" (interactive) (if (and (not org-clock-resolving-clocks-due-to-idleness) (marker-buffer org-clock-marker) (marker-buffer org-clock-interrupted-task)) (org-with-point-at org-clock-interrupted-task (org-clock-in nil)) (org-clock-out))) (global-set-key (kbd "") 'org-clock-goto) (global-set-key (kbd "C-") 'org-clock-in) (global-set-key (kbd " m") 'bh/clock-in-read-mail-and-news-task) (global-set-key (kbd " o") 'bh/clock-in-organization-task) (global-set-key (kbd " O") 'org-clock-out) (defun bh/clock-in-task-by-id (id) "Clock in a task by id" (require 'org-id) (save-restriction (widen) (org-with-point-at (org-id-find id 'marker) (org-clock-in nil)))) (defun bh/clock-in-organization-task () (interactive) (bh/clock-in-task-by-id "437c2cde-fbf0-491f-92ba-51bae487b338")) (defun bh/clock-in-read-mail-and-news-task () (interactive) (bh/clock-in-task-by-id "85c2e69b-6f37-4236-8896-4f7dd86047c1")) ----------------------------------------------------------------------