emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Issue with correctly resuming interrupted timer
@ 2010-07-23 12:59 Benjamin Beckwith
  2010-07-24  5:59 ` Bernt Hansen
  2010-07-24 14:20 ` [PATCH] Fix clocking on capture completion Bernt Hansen
  0 siblings, 2 replies; 6+ messages in thread
From: Benjamin Beckwith @ 2010-07-23 12:59 UTC (permalink / raw)
  To: emacs-orgmode

I have an issue with my particular setup when using org-capture.  Here
is my relevant capture template:

(setq org-capture-templates
      '(("t" "todo" entry
	 (file "~/Documents/Org/Refile.org")
	 "* TODO %?\n  %U\n  %a" :clock-in t :clock-resume t))

I have all tasks go to the file Refile.org as shown above.  They are
are first-level TODOs. Say I have a list of tasks such as

* TODO A (Currently clocked in)
* TODO B
* TODO C

Also let the point be on the task B line.  Now if I call org-capture
and store a task, B become the task that get clocked in after
completing the capture.  Which gives me:

* TODO A
* TODO B (Now clocked in)
* TODO C
* TODO New Capture

I believe that the issue is within org-capture-finalize and the call
to org-with-point-at, but I have exceeded my elisp debugging skills
and need help.

I am using the very latest org-mode master with emacs 23.1 on windows.
 Any ideas?

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

* Re: Issue with correctly resuming interrupted timer
  2010-07-23 12:59 Issue with correctly resuming interrupted timer Benjamin Beckwith
@ 2010-07-24  5:59 ` Bernt Hansen
  2010-07-24 14:20 ` [PATCH] Fix clocking on capture completion Bernt Hansen
  1 sibling, 0 replies; 6+ messages in thread
From: Bernt Hansen @ 2010-07-24  5:59 UTC (permalink / raw)
  To: Benjamin Beckwith; +Cc: emacs-orgmode

Benjamin Beckwith <bnbeckwith@gmail.com> writes:

> I have an issue with my particular setup when using org-capture.  Here
> is my relevant capture template:
>
> (setq org-capture-templates
>       '(("t" "todo" entry
> 	 (file "~/Documents/Org/Refile.org")
> 	 "* TODO %?\n  %U\n  %a" :clock-in t :clock-resume t))
>
> I have all tasks go to the file Refile.org as shown above.  They are
> are first-level TODOs. Say I have a list of tasks such as
>
> * TODO A (Currently clocked in)
> * TODO B
> * TODO C
>
> Also let the point be on the task B line.  Now if I call org-capture
> and store a task, B become the task that get clocked in after
> completing the capture.  Which gives me:
>
> * TODO A
> * TODO B (Now clocked in)
> * TODO C
> * TODO New Capture
>
> I believe that the issue is within org-capture-finalize and the call
> to org-with-point-at, but I have exceeded my elisp debugging skills
> and need help.
>
> I am using the very latest org-mode master with emacs 23.1 on windows.
>  Any ideas?

I can confirm this bug (sort of).  My newly 'New Capture' task keeps
clocking after filing instead of task 'B'.

It seems it works okay if you are clocking a task in a different buffer
from the refile.org target file for the capture.

In my case when I finish the capture with C-c C-c the clock stays on the
newly captured task instead of moving back to the previously clocking
task in refile.org.  If I clock a task in todo.org the clock correctly
switches to the capture task in refile.org and back to the todo.org task
when I file the captured task.

I'll look into this more on Sunday if nobody beats me to it.

-Bernt

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

* [PATCH] Fix clocking on capture completion
  2010-07-23 12:59 Issue with correctly resuming interrupted timer Benjamin Beckwith
  2010-07-24  5:59 ` Bernt Hansen
@ 2010-07-24 14:20 ` Bernt Hansen
  2010-07-24 18:41   ` Viktor Rosenfeld
  1 sibling, 1 reply; 6+ messages in thread
From: Bernt Hansen @ 2010-07-24 14:20 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bernt Hansen

* lisp/org-capture.el (org-capture-finalize): Fix clock in of interrupted
task during capture finalize

Calling org-capture-get inside the org-with-point-at macro does not
work when the current clocking task and the capture target buffer are
the same.  In this case the captured task would continue clocking
instead of switching back to the previously clocking task.
---
I think this patch fixes the issue but it should receive more testing.
Please report back if this works or not.

-Bernt


 lisp/org-capture.el |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index cf09dce..2efed78 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -467,8 +467,9 @@ bypassed."
 	       (markerp (org-capture-get :interrupted-clock 'local))
 	       (buffer-live-p (marker-buffer
 			       (org-capture-get :interrupted-clock 'local))))
-      (org-with-point-at (org-capture-get :interrupted-clock 'local)
-	(org-clock-in))
+      (let ((clock-in-task (org-capture-get :interrupted-clock 'local)))
+	(org-with-point-at clock-in-task
+	  (org-clock-in)))
       (message "Interrupted clock has been resumed")))
 
   (let ((beg (point-min))
-- 
1.7.2

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

* Re: [PATCH] Fix clocking on capture completion
  2010-07-24 14:20 ` [PATCH] Fix clocking on capture completion Bernt Hansen
@ 2010-07-24 18:41   ` Viktor Rosenfeld
  2010-07-24 18:45     ` Bernt Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: Viktor Rosenfeld @ 2010-07-24 18:41 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Hi,

this patch fixes the problem for me.  I'm on
release_7.01g.24.g6b5cf.dirty

A somewhat related question: I use your bh/clock-in-to-next function to
change the todo state to STARTED when clocking in TODO tasks.
Unfortunately it is being applied to Capture buffers.  I tried changing
the buffer-name to "CAPTURE-*" but that didn't help.

Thanks,
Viktor

Bernt Hansen wrote:

> * lisp/org-capture.el (org-capture-finalize): Fix clock in of interrupted
> task during capture finalize
> 
> Calling org-capture-get inside the org-with-point-at macro does not
> work when the current clocking task and the capture target buffer are
> the same.  In this case the captured task would continue clocking
> instead of switching back to the previously clocking task.
> ---
> I think this patch fixes the issue but it should receive more testing.
> Please report back if this works or not.
> 
> -Bernt
> 
> 
>  lisp/org-capture.el |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> index cf09dce..2efed78 100644
> --- a/lisp/org-capture.el
> +++ b/lisp/org-capture.el
> @@ -467,8 +467,9 @@ bypassed."
>  	       (markerp (org-capture-get :interrupted-clock 'local))
>  	       (buffer-live-p (marker-buffer
>  			       (org-capture-get :interrupted-clock 'local))))
> -      (org-with-point-at (org-capture-get :interrupted-clock 'local)
> -	(org-clock-in))
> +      (let ((clock-in-task (org-capture-get :interrupted-clock 'local)))
> +	(org-with-point-at clock-in-task
> +	  (org-clock-in)))
>        (message "Interrupted clock has been resumed")))
>  
>    (let ((beg (point-min))
> -- 
> 1.7.2
> 
> 
> _______________________________________________
> 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] 6+ messages in thread

* Re: [PATCH] Fix clocking on capture completion
  2010-07-24 18:41   ` Viktor Rosenfeld
@ 2010-07-24 18:45     ` Bernt Hansen
  2010-07-24 22:09       ` Viktor Rosenfeld
  0 siblings, 1 reply; 6+ messages in thread
From: Bernt Hansen @ 2010-07-24 18:45 UTC (permalink / raw)
  To: Viktor Rosenfeld; +Cc: emacs-orgmode

Viktor Rosenfeld <listuser36@googlemail.com> writes:

> this patch fixes the problem for me.  I'm on
> release_7.01g.24.g6b5cf.dirty

Thanks for the feedback.

> A somewhat related question: I use your bh/clock-in-to-next function to
> change the todo state to STARTED when clocking in TODO tasks.
> Unfortunately it is being applied to Capture buffers.  I tried changing
> the buffer-name to "CAPTURE-*" but that didn't help.

I've updated the function for capture mode but not posted the changes to
my doc.norang.ca yet.  Here's the function that works for me with
capture and remember mode.  I'm going to be removing the remember mode
logic since I no longer use that.

(defun bh/clock-in-to-next (kw)
  "Switch task from TODO to NEXT when clocking in.
Skips remember tasks and tasks with subtasks"
  (if (and (string-equal kw "TODO")
	   (not (string-equal (buffer-name) "*Remember*"))
	   (not (and (boundp 'org-capture-mode) org-capture-mode)))
      (let ((subtree-end (save-excursion (org-end-of-subtree t)))
	    (has-subtask nil))
	(save-excursion
	  (forward-line 1)
	  (while (and (not has-subtask)
		      (< (point) subtree-end)
		      (re-search-forward "^\*+ " subtree-end t))
	    (when (member (org-get-todo-state) org-not-done-keywords)
	      (setq has-subtask t))))
	(when (not has-subtask)
	  "NEXT"))))

HTH,
Bernt

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

* Re: [PATCH] Fix clocking on capture completion
  2010-07-24 18:45     ` Bernt Hansen
@ 2010-07-24 22:09       ` Viktor Rosenfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Viktor Rosenfeld @ 2010-07-24 22:09 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Hi Bernt,

thanks for the updated version.  It works as expected.

Cheers,
Viktor

Bernt Hansen wrote:

> Viktor Rosenfeld <listuser36@googlemail.com> writes:
> 
> > A somewhat related question: I use your bh/clock-in-to-next function to
> > change the todo state to STARTED when clocking in TODO tasks.
> > Unfortunately it is being applied to Capture buffers.  I tried changing
> > the buffer-name to "CAPTURE-*" but that didn't help.
> 
> I've updated the function for capture mode but not posted the changes to
> my doc.norang.ca yet.  Here's the function that works for me with
> capture and remember mode.  I'm going to be removing the remember mode
> logic since I no longer use that.
> 
> (defun bh/clock-in-to-next (kw)
>   "Switch task from TODO to NEXT when clocking in.
> Skips remember tasks and tasks with subtasks"
>   (if (and (string-equal kw "TODO")
> 	   (not (string-equal (buffer-name) "*Remember*"))
> 	   (not (and (boundp 'org-capture-mode) org-capture-mode)))
>       (let ((subtree-end (save-excursion (org-end-of-subtree t)))
> 	    (has-subtask nil))
> 	(save-excursion
> 	  (forward-line 1)
> 	  (while (and (not has-subtask)
> 		      (< (point) subtree-end)
> 		      (re-search-forward "^\*+ " subtree-end t))
> 	    (when (member (org-get-todo-state) org-not-done-keywords)
> 	      (setq has-subtask t))))
> 	(when (not has-subtask)
> 	  "NEXT"))))

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

end of thread, other threads:[~2010-07-24 22:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-23 12:59 Issue with correctly resuming interrupted timer Benjamin Beckwith
2010-07-24  5:59 ` Bernt Hansen
2010-07-24 14:20 ` [PATCH] Fix clocking on capture completion Bernt Hansen
2010-07-24 18:41   ` Viktor Rosenfeld
2010-07-24 18:45     ` Bernt Hansen
2010-07-24 22:09       ` Viktor Rosenfeld

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