From: Carsten Dominik <carsten.dominik@gmail.com>
To: Kai Tetzlaff <kai.tetzlaff@gmx.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Avoid losing persisted clock data when exiting emac without loading org-mode
Date: Sat, 24 Oct 2009 18:48:32 +0200 [thread overview]
Message-ID: <468CEFF9-A1C3-4888-83B6-066F2129087D@gmail.com> (raw)
In-Reply-To: <hbrkbe$o6v$1@ger.gmane.org>
Hi Kai,
On Oct 23, 2009, at 9:01 AM, Kai Tetzlaff wrote:
> Hi,
>
> i noticed that when using the org-mode clock persistence, the stored
> clock data gets deleted when i start emacs and exit again without
> turning on org-mode in between.
>
> When looking at org-clock-persistence-insinuate it looks like org-
> clock
> load will only run after org-mode gets started whereas org-clock-save
> will always be called when exiting emacs:
>
> (defun org-clock-persistence-insinuate ()
> "Set up hooks for clock persistence"
> (add-hook 'org-mode-hook 'org-clock-load)
> (add-hook 'kill-emacs-hook 'org-clock-save))
>
> Not running org-mode-hook (i.e. not starting org-mode) thus does not
> load clock data but org-clock-save overwrites any prviously saved data
> when exiting emacs.
>
> An easy fix for that would be to just add org-clock-load to e.g.
> emacs-startup-hook. But this will only work if the code in
> org-clock-load does not depend on any org-mode initialization code (or
> would require loading org-mode).
>
> So org-clock-save should probably check if org-clock-load has been
> running during the current emacs session (or if clock persistence was
> just enabled) and only then save clock data when exiting emacs. I
> tried
> to add this to the code in org-clock-save:
>
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index c7ebbf8..c0fe4e6 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -1803,7 +1803,8 @@ This function is made for clock tables."
> "Persist various clock-related data to disk.
> The details of what will be saved are regulated by the variable
> `org-clock-persist'."
> - (when org-clock-persist
> + (when (and org-clock-persist
> + (or org-clock-loaded (not (file-exists-p
> org-clock-persist-file))))
> (let (b)
> (with-current-buffer (find-file (expand-file-name
> org-clock-persist-file))
> (progn
>
>
> /Kai
>
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index c7ebbf8..c0fe4e6 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -1803,7 +1803,8 @@ This function is made for clock tables."
> "Persist various clock-related data to disk.
> The details of what will be saved are regulated by the variable
> `org-clock-persist'."
> - (when org-clock-persist
> + (when (and org-clock-persist
> + (or org-clock-loaded (not (file-exists-p org-clock-
> persist-file))))
> (let (b)
> (with-current-buffer (find-file (expand-file-name org-clock-
> persist-file))
> (progn
I see you point, but I am not convinced that you fix is the right
one. What one really wants to do is save the clock and history if and
only if the clock has been used in the current session. So I guess it
is better to create a special variable org-clock-used-in-this-session
which then will be set to t each time clock-in starts a clock
somewhere. I believe this would be a better insurance policy.
Would you like to try your hand at a patch in this spirit?
- Carsten
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
- Carsten
next prev parent reply other threads:[~2009-10-24 16:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-23 7:01 [PATCH] Avoid losing persisted clock data when exiting emac without loading org-mode Kai Tetzlaff
2009-10-24 16:48 ` Carsten Dominik [this message]
2009-10-24 17:03 ` Kai Tetzlaff
2009-10-24 18:40 ` Kai Tetzlaff
2009-10-25 8:10 ` Carsten Dominik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=468CEFF9-A1C3-4888-83B6-066F2129087D@gmail.com \
--to=carsten.dominik@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=kai.tetzlaff@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).