Function: org-timer-set-timer

org-timer-set-timer is an autoloaded, interactive and byte-compiled function defined in org-timer.el.gz.

Signature

(org-timer-set-timer &optional OPT)

Documentation

Prompt for a duration in minutes or hh:mm:ss and set a timer.

If org-timer-default-timer is not "0", suggest this value as the default duration for the timer. If a timer is already set, prompt the user if she wants to replace it.

Called with a numeric prefix argument OPT, use this numeric value as the duration of the timer in minutes.

Called with a C-u (universal-argument) prefix argument OPT, use org-timer-default-timer without prompting the user for a duration.

With two C-u (universal-argument) prefix arguments OPT, use org-timer-default-timer without prompting the user for a duration and automatically 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 (universal-argument) prefix arguments.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-timer.el.gz
;;;###autoload
(defun org-timer-set-timer (&optional opt)
  "Prompt for a duration in minutes or hh:mm:ss and set a timer.

If `org-timer-default-timer' is not \"0\", suggest this value as
the default duration for the timer.  If a timer is already set,
prompt the user if she wants to replace it.

Called with a numeric prefix argument OPT, use this numeric value as
the duration of the timer in minutes.

Called with a \\[universal-argument] prefix argument OPT, use
`org-timer-default-timer' without prompting the user for a duration.

With two \\[universal-argument] prefix arguments OPT, use
`org-timer-default-timer' without prompting the user for a duration
and automatically 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 \\[universal-argument] prefix arguments."
  (interactive "P")
  (when (and org-timer-start-time
	     (not org-timer-countdown-timer))
    (user-error "Relative timer is running.  Stop first"))
  (let* ((default-timer
	  ;; `org-timer-default-timer' used to be a number, don't choke:
	  (if (numberp org-timer-default-timer)
	      (number-to-string org-timer-default-timer)
	    org-timer-default-timer))
	 (effort-minutes
          (cond ((derived-mode-p 'org-agenda-mode)
                 (org-get-at-bol 'effort-minutes))
                ((derived-mode-p 'org-mode)
                 (let ((effort (org-entry-get nil org-effort-property)))
                   (when (org-string-nw-p effort)
                     (floor (org-duration-to-minutes effort)))))
                (t nil)))
	 (minutes (or (and (numberp opt) (number-to-string opt))
		      (and (not (equal opt '(64)))
			   effort-minutes
			   (number-to-string effort-minutes))
		      (and (consp opt) default-timer)
		      (and (stringp opt) opt)
		      (read-from-minibuffer
		       "How much time left? (minutes or h:mm:ss) "
		       (and (not (string-equal default-timer "0")) default-timer)))))
    (when (string-match "\\`[0-9]+\\'" minutes)
      (setq minutes (concat minutes ":00")))
    (if (not (string-match "[0-9]+" minutes))
	(org-timer-show-remaining-time)
      (let ((secs (org-timer-hms-to-secs (org-timer-fix-incomplete minutes))))
	(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 nil secs))
	  (setq org-timer-pause-time nil)
	  (org-timer-set-mode-line 'on))))))