|
@@ -49,7 +49,7 @@
|
|
|
(defvar org-timer-countdown-timer nil
|
|
|
"Current countdown timer.
|
|
|
This is a timer object if there is an active countdown timer,
|
|
|
-'paused' if there is a paused countdown timer, and nil
|
|
|
+`paused' if there is a paused countdown timer, and nil
|
|
|
otherwise.")
|
|
|
|
|
|
(defvar org-timer-countdown-timer-title nil
|
|
@@ -163,13 +163,12 @@ With prefix arg STOP, stop it entirely."
|
|
|
(let ((start-secs (org-float-time org-timer-start-time))
|
|
|
(pause-secs (org-float-time org-timer-pause-time)))
|
|
|
(if org-timer-countdown-timer
|
|
|
- (progn
|
|
|
- (let ((new-secs (- start-secs pause-secs)))
|
|
|
- (setq org-timer-countdown-timer
|
|
|
- (org-timer--run-countdown-timer
|
|
|
- new-secs org-timer-countdown-timer-title))
|
|
|
- (setq org-timer-start-time
|
|
|
- (time-add (current-time) (seconds-to-time new-secs)))))
|
|
|
+ (let ((new-secs (- start-secs pause-secs)))
|
|
|
+ (setq org-timer-countdown-timer
|
|
|
+ (org-timer--run-countdown-timer
|
|
|
+ new-secs org-timer-countdown-timer-title))
|
|
|
+ (setq org-timer-start-time
|
|
|
+ (time-add (current-time) (seconds-to-time new-secs))))
|
|
|
(setq org-timer-start-time
|
|
|
;; Pass `current-time' result to `org-float-time'
|
|
|
;; (instead of calling without arguments) so that only
|
|
@@ -184,10 +183,10 @@ With prefix arg STOP, stop it entirely."
|
|
|
;; pause timer
|
|
|
(when org-timer-countdown-timer
|
|
|
(cancel-timer org-timer-countdown-timer)
|
|
|
- (setq org-timer-countdown-timer 'pause))
|
|
|
+ (setq org-timer-countdown-timer 'paused))
|
|
|
(run-hooks 'org-timer-pause-hook)
|
|
|
(setq org-timer-pause-time (current-time))
|
|
|
- (org-timer-set-mode-line 'pause)
|
|
|
+ (org-timer-set-mode-line 'paused)
|
|
|
(message "Timer paused at %s" (org-timer-value-string)))))
|
|
|
|
|
|
(defun org-timer-stop ()
|
|
@@ -332,7 +331,7 @@ If the integer is negative, the string will start with \"-\"."
|
|
|
|
|
|
(defun org-timer-set-mode-line (value)
|
|
|
"Set the mode-line display for relative or countdown timer.
|
|
|
-VALUE can be `on', `off', or `pause'."
|
|
|
+VALUE can be `on', `off', or `paused'."
|
|
|
(when (or (eq org-timer-display 'mode-line)
|
|
|
(eq org-timer-display 'both))
|
|
|
(or global-mode-string (setq global-mode-string '("")))
|
|
@@ -358,7 +357,7 @@ VALUE can be `on', `off', or `pause'."
|
|
|
(setq frame-title-format
|
|
|
(delq 'org-timer-mode-line-string frame-title-format)))
|
|
|
(force-mode-line-update))
|
|
|
- ((equal value 'pause)
|
|
|
+ ((equal value 'paused)
|
|
|
(when org-timer-mode-line-timer
|
|
|
(cancel-timer org-timer-mode-line-timer)
|
|
|
(setq org-timer-mode-line-timer nil)))
|
|
@@ -450,23 +449,22 @@ using three `C-u' prefix arguments."
|
|
|
(org-timer-show-remaining-time)
|
|
|
(let ((secs (org-timer-hms-to-secs (org-timer-fix-incomplete minutes)))
|
|
|
(hl (org-timer--get-timer-title)))
|
|
|
- (if (or (not org-timer-countdown-timer)
|
|
|
- (equal opt '(16))
|
|
|
- (y-or-n-p "Replace current timer? "))
|
|
|
- (progn
|
|
|
- (when (timerp org-timer-countdown-timer)
|
|
|
- (cancel-timer org-timer-countdown-timer))
|
|
|
- (setq org-timer-countdown-timer-title
|
|
|
- (org-timer--get-timer-title))
|
|
|
- (setq org-timer-countdown-timer
|
|
|
- (org-timer--run-countdown-timer
|
|
|
- secs org-timer-countdown-timer-title))
|
|
|
- (run-hooks 'org-timer-set-hook)
|
|
|
- (setq org-timer-start-time
|
|
|
- (time-add (current-time) (seconds-to-time secs)))
|
|
|
- (setq org-timer-pause-time nil)
|
|
|
- (org-timer-set-mode-line 'on))
|
|
|
- (message "No timer set"))))))
|
|
|
+ (if (and org-timer-countdown-timer
|
|
|
+ (not (or (equal opt '(16))
|
|
|
+ (y-or-n-p "Replace current timer? "))))
|
|
|
+ (message "No timer set")
|
|
|
+ (when (timerp org-timer-countdown-timer)
|
|
|
+ (cancel-timer org-timer-countdown-timer))
|
|
|
+ (setq org-timer-countdown-timer-title
|
|
|
+ (org-timer--get-timer-title))
|
|
|
+ (setq org-timer-countdown-timer
|
|
|
+ (org-timer--run-countdown-timer
|
|
|
+ secs org-timer-countdown-timer-title))
|
|
|
+ (run-hooks 'org-timer-set-hook)
|
|
|
+ (setq org-timer-start-time
|
|
|
+ (time-add (current-time) (seconds-to-time secs)))
|
|
|
+ (setq org-timer-pause-time nil)
|
|
|
+ (org-timer-set-mode-line 'on))))))
|
|
|
|
|
|
(defun org-timer--run-countdown-timer (secs title)
|
|
|
"Start countdown timer that will last SECS.
|