forked from mirrors/org-mode
org-timer.el: hh:mm:ss format for setting a timer
* lisp/org-timer.el (org-timer-set-timer): Add support for hh:mm:ss format. (org-timer-default-timer): Type changed from number to string. * testing/lisp/test-org-timer.el (test-org-timer/set-timer): Add hh:mm:ss format in the test.
This commit is contained in:
parent
03936a50f4
commit
93cc5fb517
|
@ -65,12 +65,13 @@ the value of the timer."
|
||||||
:group 'org-time
|
:group 'org-time
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
(defcustom org-timer-default-timer 0
|
(defcustom org-timer-default-timer "0"
|
||||||
"The default timer when a timer is set.
|
"The default timer when a timer is set, in minutes or hh:mm:ss format.
|
||||||
When 0, the user is prompted for a value."
|
When 0, the user is prompted for a value."
|
||||||
:group 'org-time
|
:group 'org-time
|
||||||
:version "24.1"
|
:version "25.1"
|
||||||
:type 'number)
|
:package-version '(Org . "8.3")
|
||||||
|
:type 'string)
|
||||||
|
|
||||||
(defcustom org-timer-display 'mode-line
|
(defcustom org-timer-display 'mode-line
|
||||||
"When a timer is running, org-mode can display it in the mode
|
"When a timer is running, org-mode can display it in the mode
|
||||||
|
@ -402,14 +403,14 @@ VALUE can be `on', `off', or `pause'."
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun org-timer-set-timer (&optional opt)
|
(defun org-timer-set-timer (&optional opt)
|
||||||
"Prompt for a duration and set a timer.
|
"Prompt for a duration in minutes or hh:mm:ss and set a timer.
|
||||||
|
|
||||||
If `org-timer-default-timer' is not zero, suggest this value as
|
If `org-timer-default-timer' is not zero, suggest this value as
|
||||||
the default duration for the timer. If a timer is already set,
|
the default duration for the timer. If a timer is already set,
|
||||||
prompt the user if she wants to replace it.
|
prompt the user if she wants to replace it.
|
||||||
|
|
||||||
Called with a numeric prefix argument, use this numeric value as
|
Called with a numeric prefix argument, use this numeric value as
|
||||||
the duration of the timer.
|
the duration of the timer in minutes.
|
||||||
|
|
||||||
Called with a `C-u' prefix arguments, use `org-timer-default-timer'
|
Called with a `C-u' prefix arguments, use `org-timer-default-timer'
|
||||||
without prompting the user for a duration.
|
without prompting the user for a duration.
|
||||||
|
@ -429,18 +430,19 @@ using three `C-u' prefix arguments."
|
||||||
(minutes (or (and (not (equal opt '(64)))
|
(minutes (or (and (not (equal opt '(64)))
|
||||||
effort-minutes
|
effort-minutes
|
||||||
(number-to-string effort-minutes))
|
(number-to-string effort-minutes))
|
||||||
(and (numberp opt) (number-to-string opt))
|
(and (numberp opt) (number-to-string opt))
|
||||||
(and (listp opt) (not (null opt))
|
(and (consp opt) org-timer-default-timer)
|
||||||
(number-to-string org-timer-default-timer))
|
(and (stringp opt) opt)
|
||||||
(read-from-minibuffer
|
(read-from-minibuffer
|
||||||
"How many minutes left? "
|
"How much time left? (minutes or h:mm:ss) "
|
||||||
(if (not (eq org-timer-default-timer 0))
|
(and (not (string-equal org-timer-default-timer "0"))
|
||||||
(number-to-string org-timer-default-timer))))))
|
org-timer-default-timer)))))
|
||||||
|
(when (string-match "\\`[0-9]+\\'" minutes)
|
||||||
|
(setq minutes (concat minutes ":00")))
|
||||||
(if (not (string-match "[0-9]+" minutes))
|
(if (not (string-match "[0-9]+" minutes))
|
||||||
(org-timer-show-remaining-time)
|
(org-timer-show-remaining-time)
|
||||||
(let* ((mins (string-to-number (match-string 0 minutes)))
|
(let ((secs (org-timer-hms-to-secs (org-timer-fix-incomplete minutes)))
|
||||||
(secs (* mins 60))
|
(hl (org-timer--get-timer-title)))
|
||||||
(hl (org-timer--get-timer-title)))
|
|
||||||
(if (or (not org-timer-countdown-timer)
|
(if (or (not org-timer-countdown-timer)
|
||||||
(equal opt '(16))
|
(equal opt '(16))
|
||||||
(y-or-n-p "Replace current timer? "))
|
(y-or-n-p "Replace current timer? "))
|
||||||
|
|
|
@ -178,6 +178,14 @@ Also, mute output from `message'."
|
||||||
(org-timer-set-timer 10))
|
(org-timer-set-timer 10))
|
||||||
(test-org-timer/with-current-time test-org-timer/time1
|
(test-org-timer/with-current-time test-org-timer/time1
|
||||||
(org-timer))
|
(org-timer))
|
||||||
|
(org-trim (buffer-string)))))
|
||||||
|
(should
|
||||||
|
(equal "0:00:04"
|
||||||
|
(test-org-timer/with-temp-text ""
|
||||||
|
(test-org-timer/with-current-time test-org-timer/time0
|
||||||
|
(org-timer-set-timer "3:30"))
|
||||||
|
(test-org-timer/with-current-time test-org-timer/time1
|
||||||
|
(org-timer))
|
||||||
(org-trim (buffer-string))))))
|
(org-trim (buffer-string))))))
|
||||||
|
|
||||||
(ert-deftest test-org-timer/pause-timer ()
|
(ert-deftest test-org-timer/pause-timer ()
|
||||||
|
|
Loading…
Reference in a new issue