From 309e68b369841cbcfdc7ad56d3484d37d92f3c38 Mon Sep 17 00:00:00 2001 From: Foo Bar <4829djaskdfj@gmail.com> Date: Tue, 29 Jan 2019 21:38:07 -0800 Subject: [PATCH 1/2] Add org-pomodoro-before-start-hook as customization point. --- org-pomodoro.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/org-pomodoro.el b/org-pomodoro.el index 16de903..f5b25bf 100644 --- a/org-pomodoro.el +++ b/org-pomodoro.el @@ -257,6 +257,8 @@ whether to reset the pomodoro count next time you call `org-pomodoro'." :type 'boolean) ;; Hooks +(defvar org-pomodoro-before-start-hook nil + "Hooks run before a pomodoro is started.") (defvar org-pomodoro-started-hook nil "Hooks run when a pomodoro is started.") @@ -457,6 +459,8 @@ The argument STATE is optional. The default state is `:pomodoro`." (setq global-mode-string (append global-mode-string '(org-pomodoro-mode-line)))) + (run-hooks 'org-pomodoro-before-start-hook) + (org-pomodoro-set (or state :pomodoro)) (when (eq org-pomodoro-state :pomodoro) From 6c51ed7fe2ae15b48106584ae1bc8a12c55499b4 Mon Sep 17 00:00:00 2001 From: Foo Bar <4829djaskdfj@gmail.com> Date: Fri, 27 Sep 2019 14:46:17 -0700 Subject: [PATCH 2/2] Let the user set length of pomodoro and whether to take breaks --- org-pomodoro.el | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/org-pomodoro.el b/org-pomodoro.el index f5b25bf..9e2c022 100644 --- a/org-pomodoro.el +++ b/org-pomodoro.el @@ -443,9 +443,18 @@ invokes the handlers for finishing." (setq org-pomodoro-state state org-pomodoro-end-time (cl-case state - (:pomodoro (time-add (current-time) (* 60 org-pomodoro-length))) - (:short-break (time-add (current-time) (* 60 org-pomodoro-short-break-length))) - (:long-break (time-add (current-time) (* 60 org-pomodoro-long-break-length)))) + (:pomodoro + (time-add (current-time) + (* 60 (string-to-int (read-string "Pomodoro duration: " + (format "%s" org-pomodoro-length)))))) + (:short-break + (time-add (current-time) + (* 60 (string-to-int (read-string "Short break duration: " + (format "%s" org-pomodoro-short-break-length)))))) + (:long-break + (time-add (current-time) + (* 60 (string-to-int (read-string "Long break duration: " + (format "%s" org-pomodoro-long-break-length))))))) org-pomodoro-timer (run-with-timer t 1 'org-pomodoro-tick))) (defun org-pomodoro-start (&optional state) @@ -492,8 +501,10 @@ This may send a notification, play a sound and start a pomodoro break." (org-pomodoro-maybe-play-sound :pomodoro) (setq org-pomodoro-count (+ org-pomodoro-count 1)) (if (zerop (mod org-pomodoro-count org-pomodoro-long-break-frequency)) - (org-pomodoro-start :long-break) - (org-pomodoro-start :short-break)) + (when (yes-or-no-p "Do you want to start a long break?") + (org-pomodoro-start :long-break)) + (when (yes-or-no-p "Do you want to start a short break?") + (org-pomodoro-start :short-break))) (org-pomodoro-notify "Pomodoro completed!" "Time for a break.") (org-pomodoro-update-mode-line) (org-agenda-maybe-redo)