From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastien Vauban" Subject: Re: Stop clock on closing emacs Date: Mon, 03 Feb 2014 13:39:25 +0100 Message-ID: <86fvo0v08y.fsf@somewhere.org> References: <20140201104512.GA10687@pedroche.uni-erfurt.de> <52ECE27B.9070505@miszellen.de> <20140201130713.GA18536@pedroche.uni-erfurt.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Igor Sosa Mayor wrote: > Am Sat, Feb 01, 2014 at 01:03:07PM +0100, Florian Beck wrote: >> Use `kill-emacs-hook': >> >> (defun org-clock-out-maybe () >> "Stop a currently running clock." >> (org-clock-out nil t)) >> >> (add-hook 'kill-emacs-hook 'org-clock-out-maybe) > > Thanks a lot. This is much better. But: are you really using this idea? A variation: --8<---------------cut here---------------start------------->8--- ;; ask the user if they wish to clock out before killing Emacs (defun my/org-query-clock-out () "Ask the user before clocking out. This is a useful function for adding to `kill-emacs-query-functions'." (if (and (featurep 'org-clock) (funcall 'org-clocking-p) (y-or-n-p "You are currently clocking time, clock out? ")) (org-clock-out) t)) ; only fails on keyboard quit or error (add-hook 'kill-emacs-query-functions 'my/org-query-clock-out) --8<---------------cut here---------------end--------------->8--- Best regards, Seb -- Sebastien Vauban