emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* help advicing org-todo
@ 2013-01-03 16:02 Luca Ferrari
  2013-01-03 16:48 ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Luca Ferrari @ 2013-01-03 16:02 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,
I'd like to advice the function org-todo to check in and check out the
clock automatically.
I've defined the org-todo-keywords so that they have a choice letter as follows:

(setq org-todo-keywords
      '( (sequence "TODO(t!)" "|" "DONE(d!)")
         (sequence "FEATURE(f!)" "BUG(b!)"  "IMPLEMENTING(i!)" "|"
"COMPLETED(c!)")
         ))

and I'd like to start the clock each time the "i" (implementing) is
chosen, stopping the clock each time the "c" (completed) is selected.
However I've a little problem doing the advice because the argument is
null and therefore I don't know which letter the user has pressed.
Anyone can provide a little help?

Thanks,
Luca

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

* Re: help advicing org-todo
  2013-01-03 16:02 help advicing org-todo Luca Ferrari
@ 2013-01-03 16:48 ` Bastien
  2013-01-03 17:16   ` Luca Ferrari
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2013-01-03 16:48 UTC (permalink / raw)
  To: Luca Ferrari; +Cc: emacs-orgmode

Hi Luca,

Luca Ferrari <fluca1978@infinito.it> writes:

> I'd like to advice the function org-todo to check in and check out the
> clock automatically.

I would not advice `org-todo', I would explore the idea of adding a
function to `org-after-todo-state-change-hook'.

> I've defined the org-todo-keywords so that they have a choice letter as follows:
>
> (setq org-todo-keywords
>       '( (sequence "TODO(t!)" "|" "DONE(d!)")
>          (sequence "FEATURE(f!)" "BUG(b!)"  "IMPLEMENTING(i!)" "|"
> "COMPLETED(c!)")
>          ))
>
> and I'd like to start the clock each time the "i" (implementing) is
> chosen, stopping the clock each time the "c" (completed) is selected.

You can use (setq org-clock-out-when-done t) for this.

> However I've a little problem doing the advice because the argument is
> null and therefore I don't know which letter the user has pressed.
> Anyone can provide a little help?

HTH,

-- 
 Bastien

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

* Re: help advicing org-todo
  2013-01-03 16:48 ` Bastien
@ 2013-01-03 17:16   ` Luca Ferrari
  2013-01-03 17:25     ` Nick Dokos
  2013-01-04 15:27     ` Bastien
  0 siblings, 2 replies; 6+ messages in thread
From: Luca Ferrari @ 2013-01-03 17:16 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Thanks,
a very good advice. Now, forgive my lisp ignorance, but I've defined
the following function to do what I want:

(defun org-todo-automatic-clock ()
  "Starts/Stops the clock when a task is marked as implementing or completed"
  (if (string= state org-todo-fluca1978-running)
      (org-clock-in)
    (if (or (string= state last-state) (string= state
org-todo-fluca1978-suspended))
        (org-clock-out)
      )
    )
  )                                     ;end of defun


the problem is how to tell the org-todo-keyword to use variables
instead of strings, since the following is not working:

(setq org-todo-fluca1978-running   "IMPLEMENTING(i!)" )
(setq org-todo-fluca1978-suspended "SUSPENDED(s!)" )

(setq org-todo-keywords
      '(
         (sequence "FEATURE(f!)" "BUG(b!)"
'org-todo-fluca1978-running 'org-todo-fluca1978-suspended "|"
"COMPLETED(c!)")
         ))

What am I missing here?

Thanks,
Luca

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

* Re: help advicing org-todo
  2013-01-03 17:16   ` Luca Ferrari
@ 2013-01-03 17:25     ` Nick Dokos
  2013-01-04 15:27     ` Bastien
  1 sibling, 0 replies; 6+ messages in thread
From: Nick Dokos @ 2013-01-03 17:25 UTC (permalink / raw)
  To: Luca Ferrari; +Cc: Bastien, emacs-orgmode

Luca Ferrari <fluca1978@infinito.it> wrote:

> Thanks,
> a very good advice. Now, forgive my lisp ignorance, but I've defined
> the following function to do what I want:
> 
> (defun org-todo-automatic-clock ()
>   "Starts/Stops the clock when a task is marked as implementing or completed"
>   (if (string= state org-todo-fluca1978-running)
>       (org-clock-in)
>     (if (or (string= state last-state) (string= state
> org-todo-fluca1978-suspended))
>         (org-clock-out)
>       )
>     )
>   )                                     ;end of defun
> 
> 
> the problem is how to tell the org-todo-keyword to use variables
> instead of strings, since the following is not working:
> 
> (setq org-todo-fluca1978-running   "IMPLEMENTING(i!)" )
> (setq org-todo-fluca1978-suspended "SUSPENDED(s!)" )
> 
> (setq org-todo-keywords
>       '(
>          (sequence "FEATURE(f!)" "BUG(b!)"
> 'org-todo-fluca1978-running 'org-todo-fluca1978-suspended "|"
> "COMPLETED(c!)")
>          ))
> 
> What am I missing here?
> 

OTTOMH: Should state be org-state instead?

Nick

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

* Re: help advicing org-todo
  2013-01-03 17:16   ` Luca Ferrari
  2013-01-03 17:25     ` Nick Dokos
@ 2013-01-04 15:27     ` Bastien
  2013-01-07  7:27       ` Luca Ferrari
  1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2013-01-04 15:27 UTC (permalink / raw)
  To: Luca Ferrari; +Cc: emacs-orgmode

Hi Luca,

Luca Ferrari <fluca1978@infinito.it> writes:

> a very good advice. Now, forgive my lisp ignorance, but I've defined
> the following function to do what I want:

...

Actually you can simply use

(setq org-clock-in-switch-to-state "STRT")
(setq org-clock-out-switch-to-state "DONE")

HTH,

-- 
 Bastien

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

* Re: help advicing org-todo
  2013-01-04 15:27     ` Bastien
@ 2013-01-07  7:27       ` Luca Ferrari
  0 siblings, 0 replies; 6+ messages in thread
From: Luca Ferrari @ 2013-01-07  7:27 UTC (permalink / raw)
  To: emacs-orgmode

This is great!

Thanks,
Luca


> (setq org-clock-in-switch-to-state "STRT")
> (setq org-clock-out-switch-to-state "DONE")
>

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

end of thread, other threads:[~2013-01-07  7:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-03 16:02 help advicing org-todo Luca Ferrari
2013-01-03 16:48 ` Bastien
2013-01-03 17:16   ` Luca Ferrari
2013-01-03 17:25     ` Nick Dokos
2013-01-04 15:27     ` Bastien
2013-01-07  7:27       ` Luca Ferrari

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