Function: org-clock--auto-clockout-maybe

org-clock--auto-clockout-maybe is a byte-compiled function defined in org-clock.el.gz.

Signature

(org-clock--auto-clockout-maybe)

Documentation

Clock out the currently clocked in task when idle.

See org-clock-auto-clockout-timer to set the idle time span.

This function is to be called by a timer.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-clock.el.gz
(defun org-clock--auto-clockout-maybe ()
  "Clock out the currently clocked in task when idle.
See `org-clock-auto-clockout-timer' to set the idle time span.

This function is to be called by a timer."
  (when (and (numberp org-clock-auto-clockout-timer)
	     org-clock-current-task)
    (let ((user-idle-seconds (org-user-idle-seconds)))
      (cond
       ;; Already idle.  Clock out.
       ((>= user-idle-seconds org-clock-auto-clockout-timer)
        (setq org-clock--auto-clockout-timer-obj nil)
        (org-clock-out))
       ;; Emacs is idle but system is not.  Retry assuming that system will remain idle.
       ((>= (org-emacs-idle-seconds) org-clock-auto-clockout-timer)
        (setq org-clock--auto-clockout-timer-obj
              (run-with-timer
               (- org-clock-auto-clockout-timer user-idle-seconds)
               nil #'org-clock--auto-clockout-maybe)))
       ;; Emacs is not idle.  Check again next time we are idle.
       (t
        (setq org-clock--auto-clockout-timer-obj
              (run-with-idle-timer
               org-clock-auto-clockout-timer nil #'org-clock--auto-clockout-maybe)))))))