emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [org-clock] default clock for non-org-mode buffers
@ 2010-02-10 17:49 Austin Frank
  2010-02-12 14:58 ` Bernt Hansen
  0 siblings, 1 reply; 4+ messages in thread
From: Austin Frank @ 2010-02-10 17:49 UTC (permalink / raw)
  To: emacs-orgmode


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

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?

Thanks,
/au
  
-- 
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	[flat|nested] 4+ messages in thread

* Re: [org-clock] default clock for non-org-mode buffers
  2010-02-10 17:49 [org-clock] default clock for non-org-mode buffers Austin Frank
@ 2010-02-12 14:58 ` Bernt Hansen
  2010-02-18  9:09   ` Sébastien Vauban
  0 siblings, 1 reply; 4+ messages in thread
From: Bernt Hansen @ 2010-02-12 14:58 UTC (permalink / raw)
  To: Austin Frank; +Cc: emacs-orgmode

Austin Frank <austin.frank@gmail.com> 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 "<f11>") 'org-clock-goto)
(global-set-key (kbd "C-<f11>") 'org-clock-in)

(global-set-key (kbd "<f9> m") 'bh/clock-in-read-mail-and-news-task)
(global-set-key (kbd "<f9> o") 'bh/clock-in-organization-task)
(global-set-key (kbd "<f9> 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"))

----------------------------------------------------------------------

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

* Re: [org-clock] default clock for non-org-mode buffers
  2010-02-12 14:58 ` Bernt Hansen
@ 2010-02-18  9:09   ` Sébastien Vauban
  2010-02-18 17:14     ` Bernt Hansen
  0 siblings, 1 reply; 4+ messages in thread
From: Sébastien Vauban @ 2010-02-18  9:09 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Bernt,

Bernt Hansen wrote:
> 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.

I've just tried your process, and I find it really, really nice.

Though, I have a few questions about it, or about how I can do to make it
better suit my needs or particularities.

Let me explain.

I clock-in the task "Read Emails and News". I find a nice post, from which I
wanna keep a copy (it was the case with yours, for example), at least of some
part of it. I select a region, and call remember with the template:

--8<---------------cut here---------------start------------->8---
            ("Org-mode" ?o
             "* %^{Title}\n\n  %i\n\n  From the %a"
             "~/Public/Documentation-on-Org-mode.txt"
             "Documentation on Org-mode")
--8<---------------cut here---------------end--------------->8---

(BTW, `.txt' files are Org-mode files in my config)

What is annoying now is that the clock will be stopped for task "Emails and
News" while I really have not changed of activity. And I don't want to clock
in anything special for the simple copy I made of a news posting. Here, I
would expect the started clocked to go on as if nothing happened -- ignoring
the "clock switching stuff" for that particular remember template.

This is completely different if I am interrupted by the phone (client call) or
by a mail which requires a long response to a client (and needs to be
correctly tracked). For these, I will also make use of the remember templates,
such as:

--8<---------------cut here---------------start------------->8---
            ("Note" ?n
             "* %U %?\n\n  %i\n  From the %a"
             nil
             "Notes")
--8<---------------cut here---------------end--------------->8---

and I want the standard "Read Emails and News" clock to be temporarily
stopped, while the call will be tracked appropriately for a client project.

So, is there a way to merge those 2 points of view into one functionality?

Hope my text is clear enough for you all to understand what I mean.

Best regards and Thanks for having shared!

Seb

-- 
Sébastien Vauban



_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [org-clock] default clock for non-org-mode buffers
  2010-02-18  9:09   ` Sébastien Vauban
@ 2010-02-18 17:14     ` Bernt Hansen
  0 siblings, 0 replies; 4+ messages in thread
From: Bernt Hansen @ 2010-02-18 17:14 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
writes:

> Hi Bernt,
>
> Bernt Hansen wrote:
>> 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.
>
> I've just tried your process, and I find it really, really nice.
>
> Though, I have a few questions about it, or about how I can do to make it
> better suit my needs or particularities.
>
> Let me explain.
>
> I clock-in the task "Read Emails and News". I find a nice post, from which I
> wanna keep a copy (it was the case with yours, for example), at least of some
> part of it. I select a region, and call remember with the template:
>
> --8<---------------cut here---------------start------------->8---
>             ("Org-mode" ?o
>              "* %^{Title}\n\n  %i\n\n  From the %a"
>              "~/Public/Documentation-on-Org-mode.txt"
>              "Documentation on Org-mode")
> --8<---------------cut here---------------end--------------->8---
>
> (BTW, `.txt' files are Org-mode files in my config)
>
> What is annoying now is that the clock will be stopped for task "Emails and
> News" while I really have not changed of activity. And I don't want to clock
> in anything special for the simple copy I made of a news posting. Here, I
> would expect the started clocked to go on as if nothing happened -- ignoring
> the "clock switching stuff" for that particular remember template.
>
> This is completely different if I am interrupted by the phone (client call) or
> by a mail which requires a long response to a client (and needs to be
> correctly tracked). For these, I will also make use of the remember templates,
> such as:
>
> --8<---------------cut here---------------start------------->8---
>             ("Note" ?n

>              "* %U %?\n\n  %i\n  From the %a"
>              nil
>              "Notes")
> --8<---------------cut here---------------end--------------->8---
>
> and I want the standard "Read Emails and News" clock to be temporarily
> stopped, while the call will be tracked appropriately for a client project.
>
> So, is there a way to merge those 2 points of view into one functionality?
>
> Hope my text is clear enough for you all to understand what I mean.

I used to have a special remember hook to only clock in remember
templates with a :CLOCK-IN: marker in the text.  I've since simplified
my use of remember and just clock everything -- I don't have to remember
to clock it - it just happens.

For your case I would just hit F9-SPC (mapped to
bh/clock-in-interrupted-task) to switch the clock back after entering
the remember template and again after saving it (since saving it
switches back to the remember task clock)

ie.
  - clock stuff
  - enter remember mode (clock switches)
  - F9-SPC (switch back)
  - enter your remember details (take as long as you like)
  - C-c C-c (clock switches again, so you need to switch back)
  - F9-SPC (switch back)

The hook could probably be made smart enough not to clock in the newly
saved remember task.

I just ignore that though - I just let it clock my time creating the
remember note - usually that's less than a minute anyway so the clock
drawer ends up empty. (I remove zero clocks)

HTH,
Bernt

PS. I almost missed this mail since it wasn't addressed to me.

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

end of thread, other threads:[~2010-02-18 17:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 17:49 [org-clock] default clock for non-org-mode buffers Austin Frank
2010-02-12 14:58 ` Bernt Hansen
2010-02-18  9:09   ` Sébastien Vauban
2010-02-18 17:14     ` Bernt Hansen

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