emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Stop clock on closing emacs
@ 2014-01-31 12:47 Igor Sosa Mayor
  0 siblings, 0 replies; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-01-31 12:47 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

is there any hook to stop automatically a running clock when closing
emacs? 

I can't find anything neither in the manual nor in internet...

many thanks in advance.

-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stop clock on closing emacs
@ 2014-02-01  6:23 Rustom Mody
  2014-02-01 10:45 ` Igor Sosa Mayor
  0 siblings, 1 reply; 9+ messages in thread
From: Rustom Mody @ 2014-02-01  6:23 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

Igor wrote
> Hi,
>
> is there any hook to stop automatically a running clock when closing
> emacs?
>
> I can't find anything neither in the manual nor in internet...


In (info "(org)Clocking Work Time")

is given this:
  (setq org-clock-persist 'history)
  (org-clock-persistence-insinuate)

They dont work??

[-- Attachment #2: Type: text/html, Size: 428 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stop clock on closing emacs
  2014-02-01  6:23 Stop clock on closing emacs Rustom Mody
@ 2014-02-01 10:45 ` Igor Sosa Mayor
  2014-02-01 12:03   ` Florian Beck
  0 siblings, 1 reply; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-02-01 10:45 UTC (permalink / raw)
  To: emacs-orgmode

Am Sat, Feb 01, 2014 at 11:53:09AM +0530, Rustom Mody wrote:
> In (info "(org)Clocking Work Time")
> 
> is given this:
>   (setq org-clock-persist 'history)
>   (org-clock-persistence-insinuate)

I have both in my configuration and the clock is not being stopped when
I close emacs. It is saved and I can recover it the next time, but this
is something different. I would like emacs/orgmode to insert the time
I'm closing emacs as end time of the running clock. 

Thanks in any case for your answer.


-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stop clock on closing emacs
  2014-02-01 10:45 ` Igor Sosa Mayor
@ 2014-02-01 12:03   ` Florian Beck
  2014-02-01 13:07     ` Igor Sosa Mayor
  0 siblings, 1 reply; 9+ messages in thread
From: Florian Beck @ 2014-02-01 12:03 UTC (permalink / raw)
  To: Org Mode List

On 01.02.2014 11:45, Igor Sosa Mayor wrote:
> I would like emacs/orgmode to insert the time
> I'm closing emacs as end time of the running clock.

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)



-- 
Florian Beck

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stop clock on closing emacs
  2014-02-01 12:03   ` Florian Beck
@ 2014-02-01 13:07     ` Igor Sosa Mayor
  2014-02-01 13:58       ` Florian Beck
  2014-02-03 12:39       ` Sebastien Vauban
  0 siblings, 2 replies; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-02-01 13:07 UTC (permalink / raw)
  To: emacs-orgmode

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?
The problem is that the kill-emacs-hook does not ask for save the
modified buffer. That means: I see that the end time is being put into
the org buffer, but the buffer/file is not being saved...

I solved the problem (but maybe there is a more elegant way...) adding
the following:

(defun org-clock-out-maybe ()
   "Stop a currently running clock."
   (org-clock-out nil t)
   (org-save-all-org-buffers))


   
-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stop clock on closing emacs
  2014-02-01 13:07     ` Igor Sosa Mayor
@ 2014-02-01 13:58       ` Florian Beck
  2014-02-01 18:25         ` Igor Sosa Mayor
  2014-02-03 12:39       ` Sebastien Vauban
  1 sibling, 1 reply; 9+ messages in thread
From: Florian Beck @ 2014-02-01 13:58 UTC (permalink / raw)
  To: emacs-orgmode

On 01.02.2014 14:07, Igor Sosa Mayor wrote:

> Thanks a lot. This is much better. But: are you really using this idea?
> The problem is that the kill-emacs-hook does not ask for save the
> modified buffer. That means: I see that the end time is being put into
> the org buffer, but the buffer/file is not being saved...

You are right. I didn't think of this because...

>
> I solved the problem (but maybe there is a more elegant way...) adding
> the following:
>
> (defun org-clock-out-maybe ()
>     "Stop a currently running clock."
>     (org-clock-out nil t)
>     (org-save-all-org-buffers))
>

... I call `save-all-buffer' in the exit hook.

Sorry for the confusion.

-- 
Florian Beck

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stop clock on closing emacs
  2014-02-01 13:58       ` Florian Beck
@ 2014-02-01 18:25         ` Igor Sosa Mayor
  0 siblings, 0 replies; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-02-01 18:25 UTC (permalink / raw)
  To: emacs-orgmode

Am Sat, Feb 01, 2014 at 02:58:23PM +0100, Florian Beck wrote:
> ... I call `save-all-buffer' in the exit hook.
> 
> Sorry for the confusion.

on the contrary! Your hint was very helpful! I have finally this working
and I'm very happy with it!

-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stop clock on closing emacs
  2014-02-01 13:07     ` Igor Sosa Mayor
  2014-02-01 13:58       ` Florian Beck
@ 2014-02-03 12:39       ` Sebastien Vauban
  2014-02-08 23:00         ` Igor Sosa Mayor
  1 sibling, 1 reply; 9+ messages in thread
From: Sebastien Vauban @ 2014-02-03 12:39 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stop clock on closing emacs
  2014-02-03 12:39       ` Sebastien Vauban
@ 2014-02-08 23:00         ` Igor Sosa Mayor
  0 siblings, 0 replies; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-02-08 23:00 UTC (permalink / raw)
  To: emacs-orgmode

Am Mon, Feb 03, 2014 at 01:39:25PM +0100, Sebastien Vauban wrote:
> 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---

thanks! I will give it a try!

-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-02-08 23:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-01  6:23 Stop clock on closing emacs Rustom Mody
2014-02-01 10:45 ` Igor Sosa Mayor
2014-02-01 12:03   ` Florian Beck
2014-02-01 13:07     ` Igor Sosa Mayor
2014-02-01 13:58       ` Florian Beck
2014-02-01 18:25         ` Igor Sosa Mayor
2014-02-03 12:39       ` Sebastien Vauban
2014-02-08 23:00         ` Igor Sosa Mayor
  -- strict thread matches above, loose matches on Subject: below --
2014-01-31 12:47 Igor Sosa Mayor

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).