Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Prompt for new pomodoro after break #89

Open
alienbogart opened this issue Apr 23, 2020 · 11 comments
Open

[Request] Prompt for new pomodoro after break #89

alienbogart opened this issue Apr 23, 2020 · 11 comments

Comments

@alienbogart
Copy link

It would be nice to get a prompt to start a new pomodoro after breaks. Thanks!

@pth91
Copy link

pth91 commented May 5, 2020

Is there any functionality activating another pomodoro after either break automatically yet? I can not seem to find it, if it exists.

@telotortium
Copy link
Contributor

Add a hook to org-pomodoro-break-finished-hook?

@pth91
Copy link

pth91 commented May 5, 2020

I know this is not the sapce to ask something like this, but I am new to emacs/lisp. So the obvious question is, how would one do that?

@telotortium
Copy link
Contributor

I think this should do it:

(add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro)

This will start a pomodoro immediately after both a short and a long break. If you want it to run after just a short break, it's a little more complicated.

@pth91
Copy link

pth91 commented May 5, 2020

It works!

Although the new clock-in happens under the task where the cursor is located, once the new timer is started.

So one would have to jump to the current clocking task before this created "hook-timer" starts.

@telotortium
Copy link
Contributor

Ah, yes, then you need something like this:

(defun my/org-pomodoro-resume-after-break ()
  "Resume Org Pomodoro after break is finished."
  (org-clock-goto)
  (org-pomodoro))
(add-hook 'org-pomodoro-break-finished-hook #'my/org-pomodoro-resume-after-break)

@pth91
Copy link

pth91 commented May 7, 2020

So, I tried your last suggestion, and it works smoothly. Thank you again!

@alienbogart
Copy link
Author

(add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro)

This will start a pomodoro immediately after both a short and a long break. If you want it to run after just a short break, it's a little more complicated.

This would immediately start another Pomodoro in the current header. I meant something different: a prompt or dialogue (those with "Yes" or "No") so I can just press "Y" or "Yes" for a new Pomodoro. Ideally, it should go to last Pomodoro automatically. Something like:

(defun org-pomodoro-prompt ()
(interactive)
(org-clock-goto)
(org-prompt-for-pomodoro))

(add-hook 'org-pomodoro-break-finished-hook 'org-pomodoro-prompt) 

Thanks!

@gzhang8
Copy link

gzhang8 commented Sep 29, 2020

(add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro)

This will start a pomodoro immediately after both a short and a long break. If you want it to run after just a short break, it's a little more complicated.

This would immediately start another Pomodoro in the current header. I meant something different: a prompt or dialogue (those with "Yes" or "No") so I can just press "Y" or "Yes" for a new Pomodoro. Ideally, it should go to last Pomodoro automatically. Something like:

(defun org-pomodoro-prompt ()
(interactive)
(org-clock-goto)
(org-prompt-for-pomodoro))

(add-hook 'org-pomodoro-break-finished-hook 'org-pomodoro-prompt) 

Thanks!

Maybe it's not perfect. This works for me.

(defun org-pomodoro-prompt ()
(interactive)
(org-clock-goto)
(if (y-or-n-p "Start a new pomodoro?")
    (progn
      (org-pomodoro))))

(add-hook 'org-pomodoro-break-finished-hook 'org-pomodoro-prompt) 

@pmnerfed
Copy link

I would love it if there was a variable in the package itself to allow autostart timer after break.

@rosetail
Copy link

rosetail commented Mar 4, 2022

I just modified the prompt function so now it doesn't switch buffers all of a sudden when your break ends.

(defun my/org-pomodoro-restart ()
  (interactive)
  (when (y-or-n-p "Start a new pomodoro?")
    (save-window-excursion
      (org-clock-goto)
      (org-pomodoro))))

(add-hook 'org-pomodoro-break-finished-hook 'my/org-pomodoro-restart) 

Also, if you want a minibuffer popup instead of a gui one, use the following instead

(defun my/org-pomodoro-restart ()
  (interactive)
  (let ((use-dialog-box nil))
  (when (y-or-n-p "Start a new pomodoro?")
    (save-window-excursion
      (org-clock-goto)
      (org-pomodoro)))))

(add-hook 'org-pomodoro-break-finished-hook 'my/org-pomodoro-restart) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants