|
@@ -485,6 +485,17 @@ is added to the user configuration."
|
|
(integer :tag "Clock out after Emacs is idle for X seconds")
|
|
(integer :tag "Clock out after Emacs is idle for X seconds")
|
|
(const :tag "Never auto clock out" nil)))
|
|
(const :tag "Never auto clock out" nil)))
|
|
|
|
|
|
|
|
+(defcustom org-clock-ask-before-exiting t
|
|
|
|
+ "If non-nil, ask if the user wants to clock out before exiting Emacs.
|
|
|
|
+This variable only has effect if set with \\[customize]."
|
|
|
|
+ :set (lambda (symbol value)
|
|
|
|
+ (if value
|
|
|
|
+ (add-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query)
|
|
|
|
+ (remove-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query))
|
|
|
|
+ (set symbol value))
|
|
|
|
+ :type 'boolean
|
|
|
|
+ :package-version '(Org . "9.5"))
|
|
|
|
+
|
|
(defvar org-clock-in-prepare-hook nil
|
|
(defvar org-clock-in-prepare-hook nil
|
|
"Hook run when preparing the clock.
|
|
"Hook run when preparing the clock.
|
|
This hook is run before anything happens to the task that
|
|
This hook is run before anything happens to the task that
|
|
@@ -3100,6 +3111,17 @@ The details of what will be saved are regulated by the variable
|
|
(when (org-invisible-p) (org-show-context))))))
|
|
(when (org-invisible-p) (org-show-context))))))
|
|
(_ nil)))))
|
|
(_ nil)))))
|
|
|
|
|
|
|
|
+(defun org-clock-kill-emacs-query ()
|
|
|
|
+ "Query user when killing Emacs.
|
|
|
|
+This function is added to `kill-emacs-query-functions'."
|
|
|
|
+ (let ((buf (org-clocking-buffer)))
|
|
|
|
+ (when (and buf (yes-or-no-p "Clock out and save? "))
|
|
|
|
+ (with-current-buffer buf
|
|
|
|
+ (org-clock-out)
|
|
|
|
+ (save-buffer))))
|
|
|
|
+ ;; Unconditionally return t for `kill-emacs-query-functions'.
|
|
|
|
+ t)
|
|
|
|
+
|
|
;; Suggested bindings
|
|
;; Suggested bindings
|
|
(org-defkey org-mode-map "\C-c\C-x\C-e" 'org-clock-modify-effort-estimate)
|
|
(org-defkey org-mode-map "\C-c\C-x\C-e" 'org-clock-modify-effort-estimate)
|
|
|
|
|