Преглед изворни кода

Add `org-clock-toggle-auto-clockout'

* doc/org-manual.org: Document the new command.

* lisp/org-clock.el (org-clock-toggle-auto-clockout): New
command.
Bastien пре 6 година
родитељ
комит
a62751a6a5
2 измењених фајлова са 12 додато и 0 уклоњено
  1. 3 0
      doc/org-manual.org
  2. 9 0
      lisp/org-clock.el

+ 3 - 0
doc/org-manual.org

@@ -6901,6 +6901,9 @@ set ~org-clock-auto-clockout-timer~ to a number of seconds and add
 When the clock is running and Emacs is idle for more than this number
 When the clock is running and Emacs is idle for more than this number
 of seconds, the clock will be clocked out automatically.
 of seconds, the clock will be clocked out automatically.
 
 
+Use =M-x org-clock-toggle-auto-clockout RET= to temporarily turn this
+on or off.
+
 ** Effort Estimates
 ** Effort Estimates
 :PROPERTIES:
 :PROPERTIES:
 :DESCRIPTION: Planning work effort in advance.
 :DESCRIPTION: Planning work effort in advance.

+ 9 - 0
lisp/org-clock.el

@@ -1421,6 +1421,15 @@ is present in the user configuration."
     (run-with-idle-timer
     (run-with-idle-timer
      org-clock-auto-clockout-timer nil #'org-clock-out)))
      org-clock-auto-clockout-timer nil #'org-clock-out)))
 
 
+;;;###autoload
+(defun org-clock-toggle-auto-clockout ()
+  (interactive)
+  (if (memq 'org-clock-auto-clockout org-clock-in-hook)
+      (progn (remove-hook 'org-clock-in-hook #'org-clock-auto-clockout)
+	     (message "Auto clock-out after idle time turned off"))
+    (add-hook 'org-clock-in-hook #'org-clock-auto-clockout t)
+    (message "Auto clock-out after idle time turned on")))
+
 ;;;###autoload
 ;;;###autoload
 (defun org-clock-in-last (&optional arg)
 (defun org-clock-in-last (&optional arg)
   "Clock in the last closed clocked item.
   "Clock in the last closed clocked item.