diff options
author | Sébastien Delafond <sdelafond@gmail.com> | 2015-11-27 17:40:16 +0100 |
---|---|---|
committer | Sébastien Delafond <sdelafond@gmail.com> | 2015-11-27 17:40:16 +0100 |
commit | 09600666ecbbebe86830a937658465d046e13d06 (patch) | |
tree | f8140dfdec0fdfc11323d6c491f7680673bcc0de /lisp/org-timer.el | |
parent | 1be13d57dc8357576a8285c6dadc03db9e3ed7b0 (diff) |
Imported Upstream version 8.3.2
Diffstat (limited to 'lisp/org-timer.el')
-rw-r--r-- | lisp/org-timer.el | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/lisp/org-timer.el b/lisp/org-timer.el index 2c51b42..0758ed2 100644 --- a/lisp/org-timer.el +++ b/lisp/org-timer.el @@ -1,6 +1,6 @@ ;;; org-timer.el --- Timer code for Org mode -;; Copyright (C) 2008-2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2015 Free Software Foundation, Inc. ;; Author: Carsten Dominik <carsten at orgmode dot org> ;; Keywords: outlines, hypermedia, calendar, wp @@ -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. |