2

How to clock-out current org-task before exit from Emacs? I tried

(add-hook 'kill-emacs-hook #'org-clock-out) 

But if there is no current active tasks, Emacs says "No active clock" instead of exit. If there is an active task, in reality clock-out does not occur and the next time when I'm trying to make org-clock-in, see the proposal to resolve the conflict.

1
  • At least for the first part you can say (add-hook 'kill-emacs-hook (lambda () (org-clock-out nil t))). See the doc string for org-clock-out for the meaning of the parameters. I don't know why it does not clock out on exit though: you might want to edebug it and see if it does get called when you kill emacs. Commented May 11, 2017 at 20:23

1 Answer 1

2

Solution:

(setq org-main-file "~/orgmode/main.org") (defun valeriy/exit () (with-current-buffer (find-file-noselect org-main-file) (save-excursion (org-clock-out nil t) (save-buffer)))) (add-hook 'kill-emacs-hook #'valeriy/exit) 
3
  • What is treport/org-main-file? Commented May 14, 2017 at 20:43
  • @Nick, this is my main and only org file with tasks. (answer updated) Commented May 14, 2017 at 21:13
  • OK - I see: the "treport/" was a typo. Commented May 15, 2017 at 11:57

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.