summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2014-03-14 12:14:49 +0100
committerBastien Guerry <bzg@altern.org>2014-03-14 12:14:49 +0100
commitd49957ef021e256f19092c907d127390d39ec1ed (patch)
tree6c127ffde25579c870b97a35bfe54bcd1ec16a9c
parente75d2031bc889a346be8109db4690034b007d3ab (diff)
downloadorg-mode-d49957ef021e256f19092c907d127390d39ec1ed.tar.gz
org-timer.el: Use the number of minutes in the Effort property
* org-timer.el (org-timer-cancel-timer, org-timer-stop): Enhance message. (org-timer-set-timer): Use the number of minutes in the Effort property as the default timer value. Three prefix arguments will ignore the Effort value property.
-rw-r--r--lisp/org-timer.el37
1 files changed, 24 insertions, 13 deletions
diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index 3f52260..91d751a 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -159,12 +159,14 @@ With prefix arg STOP, stop it entirely."
(defun org-timer-stop ()
"Stop the relative timer."
(interactive)
- (run-hooks 'org-timer-stop-hook)
- (setq org-timer-start-time nil
- org-timer-pause-time nil
- org-timer-current-timer nil)
- (org-timer-set-mode-line 'off)
- (message "Timer stopped"))
+ (if (not org-timer-current-timer)
+ (message "No running timer")
+ (run-hooks 'org-timer-stop-hook)
+ (setq org-timer-start-time nil
+ org-timer-pause-time nil
+ org-timer-current-timer nil)
+ (org-timer-set-mode-line 'off)
+ (message "Timer stopped")))
;;;###autoload
(defun org-timer (&optional restart no-insert-p)
@@ -349,13 +351,14 @@ VALUE can be `on', `off', or `pause'."
(defun org-timer-cancel-timer ()
"Cancel the current timer."
(interactive)
- (when (eval org-timer-current-timer)
+ (if (not org-timer-current-timer)
+ (message "No timer to cancel")
(run-hooks 'org-timer-cancel-hook)
(cancel-timer org-timer-current-timer)
- (setq org-timer-current-timer nil)
- (setq org-timer-timer-is-countdown nil)
- (org-timer-set-mode-line 'off))
- (message "Last timer canceled"))
+ (setq org-timer-current-timer nil
+ org-timer-timer-is-countdown nil)
+ (org-timer-set-mode-line 'off)
+ (message "Last timer canceled")))
(defun org-timer-show-remaining-time ()
"Display the remaining time before the timer ends."
@@ -389,9 +392,17 @@ without prompting the user for a duration.
With two `C-u' prefix arguments, use `org-timer-default-timer'
without prompting the user for a duration and automatically
-replace any running timer."
+replace any running timer.
+
+By default, the timer duration will be set to the number of
+minutes in the Effort property, if any. You can ignore this by
+using three `C-u' prefix arguments."
(interactive "P")
- (let ((minutes (or (and (numberp opt) (number-to-string opt))
+ (let ((minutes (or (and (not (equal opt '(64)))
+ (number-to-string
+ (org-hh:mm-string-to-minutes
+ (org-entry-get (point) "effort"))))
+ (and (numberp opt) (number-to-string opt))
(and (listp opt) (not (null opt))
(number-to-string org-timer-default-timer))
(read-from-minibuffer