* [PATCH] Bugfix in org-add-log-setup.
@ 2008-10-19 16:22 James TD Smith
2008-10-19 16:22 ` [PATCH] Allow storing clock status between emacs sessions James TD Smith
2008-10-20 5:46 ` [PATCH] Bugfix in org-add-log-setup Carsten Dominik
0 siblings, 2 replies; 17+ messages in thread
From: James TD Smith @ 2008-10-19 16:22 UTC (permalink / raw)
To: emacs-orgmode
---
lisp/ChangeLog | 6 ++++++
lisp/org.el | 3 ++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 35ce9c3..ad7c9fe 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-19 James TD Smith <ahktenzero@mohorovi.cc>
+
+ * org.el (org-add-log-setup): Bugfix; code to find insertion point
+ after drawers was skipping ahead one line too many, so notes were
+ inserted after the first note instead of before it.
+
2008-10-18 Carsten Dominik <dominik@science.uva.nl>
* org-table.el (orgtbl-to-html): Bind `html-table-tag' for the
diff --git a/lisp/org.el b/lisp/org.el
index 9c08ba4..85f138d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8407,7 +8407,8 @@ EXTRA is additional text that will be inserted into the notes buffer."
(while (looking-at org-drawer-regexp)
(goto-char (match-end 0))
(re-search-forward org-property-end-re (point-max) t)
- (forward-line))))
+ (forward-line))
+ (forward-line -1)))
(unless org-log-states-order-reversed
(and (= (char-after) ?\n) (forward-char 1))
(org-skip-over-state-notes)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH] Allow storing clock status between emacs sessions.
2008-10-19 16:22 [PATCH] Bugfix in org-add-log-setup James TD Smith
@ 2008-10-19 16:22 ` James TD Smith
2008-10-20 15:42 ` Helge Gudmundsen
2008-10-20 5:46 ` [PATCH] Bugfix in org-add-log-setup Carsten Dominik
1 sibling, 1 reply; 17+ messages in thread
From: James TD Smith @ 2008-10-19 16:22 UTC (permalink / raw)
To: emacs-orgmode
Clock-related data are saved when exiting emacs ands restored when emacs
is restarted. The data saved include the contents of `org-clock-history',
and the running clock, if there is one.
To use this, you will need to add
(require 'org-clock)
(org-clock-persistence-insinuate)
to your .emacs and either add
(setq org-clock-persist t)
(setq org-clock-in-resume t)
or set those options to t in custom.
The patch also optionally changes the behaviour of `org-clock-in'; if
`org-clock-in-resume' is set, and you clock into a task with an open
clock line, org will resume the clock from that time.
Also fix a couple of typos in the changelog
---
lisp/ChangeLog | 31 +++++++++++++-
lisp/org-clock.el | 117 +++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 138 insertions(+), 10 deletions(-)
mode change 100755 => 100644 lisp/ChangeLog
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
old mode 100755
new mode 100644
index ad7c9fe..8b836eb
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,27 @@
2008-10-19 James TD Smith <ahktenzero@mohorovi.cc>
+ * org-clock.el (org-clock-persist): Add a custom option to toggle
+ clock persistence.
+ (org-clock-persist-query-save): Add a custom option to toggle
+ asking the user if they want to save the running clock when
+ exiting.
+ (org-clock-persist-query-resume): Add a custom option to toggle
+ asking the user if they want to resume the saved clock when Emacs
+ is restarted.
+ (org-clock-save): Add a function to save clock data.
+ This includes the contents of `org-clock-history' and the buffer
+ and position of the currently clocked task, if any.
+ (org-clock-load): Add a function to load clock data.
+ This populates `org-clock-history', and resumes the saved clocked
+ task if there is one.
+ (org-clock-persistence-insinuate): Add a method to set up the
+ hooks for clock persistence.
+ (org-clock-in-resume): Add a custom option to toggle starting the
+ clock from an open clock line.
+ (org-clock-in): When clocking in to an entry, if
+ `org-clock-in-resume' is set, check if the first clock line is
+ open and if so, start the clock from the time in the clock line.
+
* org.el (org-add-log-setup): Bugfix; code to find insertion point
after drawers was skipping ahead one line too many, so notes were
inserted after the first note instead of before it.
@@ -21,7 +43,7 @@
* org.el (org-clock-update-time-maybe): Compute negative clock
intervals correctly.
-2008-10-15 James TD Smith <ahktenzero@mohorovi.cc>
+2008-10-16 James TD Smith <ahktenzero@mohorovi.cc>
* org.el (org-add-log-setup): Only skip drawers if the are
immediately after the scheduling keywords.
@@ -34,6 +56,9 @@
(org-clock-in): Use org-indent-line-function to indent clock lines.
(org-clock-find-position): Fix indentation of empty clock drawers.
+ * org.el (org-add-log-setup): Only skip drawers if the are
+ immediately after the scheduling keywords.
+
2008-10-16 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-add-log-setup): Respect
@@ -125,7 +150,7 @@
* org-clock.el (org-clock-heading-for-remember): New variable.
(org-clock-in): Set `org-clock-heading-for-remember'.
-2008-10-01 James TD Smith <ahktenzero@mohorovi.cc>
+2008-10-01 James TD Smith <ahktenzero@mohorovi.cc>
* org-remember.el (org-remember-apply-template): Add new
expansions: %k, %K for currently clocked task and a link to the
@@ -234,7 +259,7 @@
* org-export-latex.el (org-export-latex-keywords-maybe): Bug fix.
-2008-09-22 James TA Smith <ahktenzero@mohorovi.cc>
+2008-09-22 James TD Smith <ahktenzero@mohorovi.cc>
* org-plot.el (org-plot/gnuplot): Make tables starting with a
hline work correctly.
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 56894cc..d932f02 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -95,6 +95,34 @@ The function is called with point at the beginning of the headline."
:group 'org-clock
:type 'integer)
+(defcustom org-clock-persist nil
+ "When non-nil, save the running clock when emacs is closed, and
+ resume it next time emacs is started."
+ :group 'org-clock
+ :type 'boolean)
+
+(defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el"
+ "File to save clock data to"
+ :group 'org-clock
+ :type 'string)
+
+(defcustom org-clock-persist-query-save nil
+ "When non-nil, ask before saving the current clock on exit"
+ :group 'org-clock
+ :type 'boolean)
+
+(defcustom org-clock-persist-query-resume t
+ "When non-nil, ask before resuming any stored clock during
+load."
+ :group 'org-clock
+ :type 'boolean)
+
+(defcustom org-clock-in-resume nil
+ "If non-nil, when clocking into a task with a clock entry which
+has not been closed, resume the clock from that point"
+ :group 'org-clock
+ :type 'boolean)
+
;;; The clock for measuring work time.
(defvar org-mode-line-string "")
@@ -291,12 +319,20 @@ the clocking selection, associated with the letter `d'."
(t "???")))
(setq org-clock-heading (org-propertize org-clock-heading 'face nil))
(org-clock-find-position)
-
- (insert "\n") (backward-char 1)
- (org-indent-line-function)
- (insert org-clock-string " ")
- (setq org-clock-start-time (current-time))
- (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
+ (setq open-clock-regex
+ (concat "^[ \\t]* " org-clock-string
+ " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\]$"))
+ (if (and org-clock-in-resume (looking-at open-clock-regex))
+ (progn (message "Matched %s" (match-string 1))
+ (setq ts (concat "[" (match-string 1) "]"))
+ (goto-char (match-end 1))
+ (setq org-clock-start-time (apply 'encode-time (org-parse-time-string (match-string 1)))))
+ (progn
+ (insert "\n") (backward-char 1)
+ (org-indent-line-function)
+ (insert org-clock-string " ")
+ (setq org-clock-start-time (current-time))
+ (setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive))))
(move-marker org-clock-marker (point) (buffer-base-buffer))
(or global-mode-string (setq global-mode-string '("")))
(or (memq 'org-mode-line-string global-mode-string)
@@ -962,7 +998,6 @@ the currently selected interval size."
(re-search-forward "#\\+END:")
(end-of-line 0))))
-
(defun org-clocktable-add-file (file table)
(if table
(let ((lines (org-split-string table "\n"))
@@ -975,6 +1010,74 @@ the currently selected interval size."
lines)
"\n"))))
+(defun org-clock-save ()
+ "Persist various clock-related data to disk"
+ (with-current-buffer (find-file (expand-file-name org-clock-persist-file))
+ (progn (delete-region (point-min) (point-max))
+ ;;Store clock
+ (insert (format ";; org-persist.el - %s at %s\n" system-name (time-stamp-string)))
+ (if (and org-clock-persist (marker-buffer org-clock-marker)
+ (or (not org-clock-persist-query-save)
+ (y-or-n-p (concat "Save current clock ("
+ (substring-no-properties org-clock-heading)
+ ")"))))
+ (insert "(setq resume-clock '(\""
+ (buffer-file-name (marker-buffer org-clock-marker))
+ "\" . " (int-to-string (marker-position org-clock-marker))
+ "))\n"))
+ ;;Store clocked task history. Tasks are stored reversed to make
+ ;;reading simpler
+ (if org-clock-history
+ (insert "(setq stored-clock-history '("
+ (mapconcat
+ (lambda (m)
+ (when (marker-buffer m)
+ (concat "(\"" (buffer-file-name (marker-buffer m))
+ "\" . " (int-to-string (marker-position m))
+ ")")))
+ (reverse org-clock-history) " ") "))\n"))
+ (save-buffer)
+ (kill-buffer (current-buffer)))))
+
+(defvar org-clock-loaded nil)
+
+(defun org-clock-load ()
+ "Load various clock-related data from disk, optionally resuming
+a stored clock"
+ (if (not org-clock-loaded)
+ (let ((filename (expand-file-name org-clock-persist-file))
+ (org-clock-in-resume t))
+ (if (file-readable-p filename)
+ (progn
+ (message "%s" "Restoring clock data")
+ (setq org-clock-loaded t)
+ (load-file filename)
+ ;; load history
+ (if (boundp 'stored-clock-history)
+ (save-window-excursion
+ (mapc (lambda (task)
+ (org-clock-history-push (cdr task)
+ (find-file (car task))))
+ stored-clock-history)))
+ ;; resume clock
+ (if (and (boundp 'resume-clock) org-clock-persist
+ (or (not org-clock-persist-query-resume)
+ (y-or-n-p "Resume clock ("
+ (with-current-buffer (find-file (car resume-clock))
+ (progn (goto-char (cdr resume-clock))
+ (looking-at org-complex-heading-regexp)
+ (match-string 4))) ")")))
+ (with-current-buffer (find-file (car resume-clock))
+ (progn (goto-char (cdr resume-clock))
+ (org-clock-in)))))
+ (message "Not restoring clock data; %s not found"
+ org-clock-persist-file)))))
+
+(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))
+
(provide 'org-clock)
;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
--
1.5.6.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] Bugfix in org-add-log-setup.
2008-10-19 16:22 [PATCH] Bugfix in org-add-log-setup James TD Smith
2008-10-19 16:22 ` [PATCH] Allow storing clock status between emacs sessions James TD Smith
@ 2008-10-20 5:46 ` Carsten Dominik
1 sibling, 0 replies; 17+ messages in thread
From: Carsten Dominik @ 2008-10-20 5:46 UTC (permalink / raw)
To: James TD Smith; +Cc: emacs-orgmode
Applied, thanks.
- Carsten
On Oct 19, 2008, at 6:22 PM, James TD Smith wrote:
> ---
> lisp/ChangeLog | 6 ++++++
> lisp/org.el | 3 ++-
> 2 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> index 35ce9c3..ad7c9fe 100755
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -1,3 +1,9 @@
> +2008-10-19 James TD Smith <ahktenzero@mohorovi.cc>
> +
> + * org.el (org-add-log-setup): Bugfix; code to find insertion point
> + after drawers was skipping ahead one line too many, so notes were
> + inserted after the first note instead of before it.
> +
> 2008-10-18 Carsten Dominik <dominik@science.uva.nl>
>
> * org-table.el (orgtbl-to-html): Bind `html-table-tag' for the
> diff --git a/lisp/org.el b/lisp/org.el
> index 9c08ba4..85f138d 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -8407,7 +8407,8 @@ EXTRA is additional text that will be inserted
> into the notes buffer."
> (while (looking-at org-drawer-regexp)
> (goto-char (match-end 0))
> (re-search-forward org-property-end-re (point-max) t)
> - (forward-line))))
> + (forward-line))
> + (forward-line -1)))
> (unless org-log-states-order-reversed
> (and (= (char-after) ?\n) (forward-char 1))
> (org-skip-over-state-notes)
> --
> 1.5.6.5
>
>
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Allow storing clock status between emacs sessions.
2008-10-19 16:22 ` [PATCH] Allow storing clock status between emacs sessions James TD Smith
@ 2008-10-20 15:42 ` Helge Gudmundsen
2008-10-22 8:45 ` Helge Gudmundsen
0 siblings, 1 reply; 17+ messages in thread
From: Helge Gudmundsen @ 2008-10-20 15:42 UTC (permalink / raw)
To: James TD Smith; +Cc: emacs-orgmode
Thanks for this one!
--
helge
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Allow storing clock status between emacs sessions.
2008-10-20 15:42 ` Helge Gudmundsen
@ 2008-10-22 8:45 ` Helge Gudmundsen
2008-10-22 9:18 ` Carsten Dominik
0 siblings, 1 reply; 17+ messages in thread
From: Helge Gudmundsen @ 2008-10-22 8:45 UTC (permalink / raw)
To: emacs-orgmode
Any chance that this patch will make it to the git repo?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Allow storing clock status between emacs sessions.
2008-10-22 8:45 ` Helge Gudmundsen
@ 2008-10-22 9:18 ` Carsten Dominik
2008-10-22 9:25 ` Helge Gudmundsen
2008-10-22 9:42 ` James TD Smith
0 siblings, 2 replies; 17+ messages in thread
From: Carsten Dominik @ 2008-10-22 9:18 UTC (permalink / raw)
To: Helge Gudmundsen; +Cc: emacs-orgmode
Hi Helge,
this is a non-trivial patch, and have not yet had the time to look at
it carefully. And I am too close to the next release 6.10, which will
likely be the final version that will make it into Emacs 23, so I do
not feel comfortable to add it now. After 6.10, good chances, yes.
You can help by stress testing it, so that we can find bugs even
before we install it.
- Carsten
On Oct 22, 2008, at 10:45 AM, Helge Gudmundsen wrote:
> Any chance that this patch will make it to the git repo?
>
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Allow storing clock status between emacs sessions.
2008-10-22 9:18 ` Carsten Dominik
@ 2008-10-22 9:25 ` Helge Gudmundsen
2008-10-22 9:42 ` James TD Smith
1 sibling, 0 replies; 17+ messages in thread
From: Helge Gudmundsen @ 2008-10-22 9:25 UTC (permalink / raw)
To: emacs-orgmode
Sure thing, I will test it (he said, while frantically typing 'man
patch' in a terminal window).
Best regards,
Helge
(and once again, thanks for org-mode, which has ended my search for
the perfect note-taking and organizing application)
On Wed, Oct 22, 2008 at 10:18 AM, Carsten Dominik
<dominik@science.uva.nl> wrote:
> Hi Helge,
>
> this is a non-trivial patch, and have not yet had the time to look at it
> carefully. And I am too close to the next release 6.10, which will likely
> be the final version that will make it into Emacs 23, so I do not feel
> comfortable to add it now. After 6.10, good chances, yes.
>
> You can help by stress testing it, so that we can find bugs even before we
> install it.
>
> - Carsten
>
> On Oct 22, 2008, at 10:45 AM, Helge Gudmundsen wrote:
>
>> Any chance that this patch will make it to the git repo?
>>
>>
>> _______________________________________________
>> 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
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Allow storing clock status between emacs sessions.
2008-10-22 9:18 ` Carsten Dominik
2008-10-22 9:25 ` Helge Gudmundsen
@ 2008-10-22 9:42 ` James TD Smith
2008-10-22 15:23 ` Carsten Dominik
1 sibling, 1 reply; 17+ messages in thread
From: James TD Smith @ 2008-10-22 9:42 UTC (permalink / raw)
To: emacs-orgmode
Hi Carsten,
On 2008-10-22 11:18:59(+0200), Carsten Dominik wrote:
> this is a non-trivial patch, and have not yet had the time to look at
> it carefully. And I am too close to the next release 6.10, which will
> likely be the final version that will make it into Emacs 23, so I do
> not feel comfortable to add it now. After 6.10, good chances, yes.
>
> You can help by stress testing it, so that we can find bugs even
> before we install it.
I've already noticed a few minor problems, and will be posting a revised version
of the patch soon, so keeping it out of 6.10 is probably best.
If you want, I will split out the patch into three smaller patches; the
changelog corrections, resuming clocking from an open clock line on clocking in,
and saving/restoring `org-clock-history' and the running clock. The changelog
corrections at least ought to make it into 6.10 :).
James
--
|-<James TD Smith>-<email/ahktenzero@mohorovi.cc>-|
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Allow storing clock status between emacs sessions.
2008-10-22 9:42 ` James TD Smith
@ 2008-10-22 15:23 ` Carsten Dominik
2008-10-23 10:27 ` [PATCH 0/3] Split my clock resume/clock persistence patch James TD Smith
0 siblings, 1 reply; 17+ messages in thread
From: Carsten Dominik @ 2008-10-22 15:23 UTC (permalink / raw)
To: James TD Smith; +Cc: emacs-orgmode
On Oct 22, 2008, at 11:42 AM, James TD Smith wrote:
> Hi Carsten,
>
> On 2008-10-22 11:18:59(+0200), Carsten Dominik wrote:
>> this is a non-trivial patch, and have not yet had the time to look
>> at
>> it carefully. And I am too close to the next release 6.10, which
>> will
>> likely be the final version that will make it into Emacs 23, so I do
>> not feel comfortable to add it now. After 6.10, good chances, yes.
>>
>> You can help by stress testing it, so that we can find bugs even
>> before we install it.
>
> I've already noticed a few minor problems, and will be posting a
> revised version
> of the patch soon, so keeping it out of 6.10 is probably best.
>
> If you want, I will split out the patch into three smaller patches;
> the
> changelog corrections, resuming clocking from an open clock line on
> clocking in,
> and saving/restoring `org-clock-history' and the running clock. The
> changelog
> corrections at least ought to make it into 6.10 :).
Did I mess up the ChangeLog again? Sorry about that, maybe a merge
problem. I think git merge does not like the ChangeLog file
structure....
Yes, please, this patch separately.
- Carsten
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 0/3] Split my clock resume/clock persistence patch
2008-10-22 15:23 ` Carsten Dominik
@ 2008-10-23 10:27 ` James TD Smith
2008-10-23 10:27 ` [PATCH 1/3] Fix some typos and duplication in the ChangeLog James TD Smith
0 siblings, 1 reply; 17+ messages in thread
From: James TD Smith @ 2008-10-23 10:27 UTC (permalink / raw)
To: emacs-orgmode
I've split this patch out into three parts, as requested.
James TD Smith (3):
Fix some typos and duplication in the ChangeLog
Add clock resuming.
Add clock persistence.
lisp/ChangeLog | 46 ++++++++++++++++-----
lisp/org-clock.el | 118 +++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 146 insertions(+), 18 deletions(-)
mode change 100755 => 100644 lisp/ChangeLog
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/3] Fix some typos and duplication in the ChangeLog
2008-10-23 10:27 ` [PATCH 0/3] Split my clock resume/clock persistence patch James TD Smith
@ 2008-10-23 10:27 ` James TD Smith
2008-10-23 10:27 ` [PATCH 2/3] Add clock resuming James TD Smith
2008-10-24 4:55 ` [PATCH 1/3] Fix some typos and duplication in the ChangeLog Carsten Dominik
0 siblings, 2 replies; 17+ messages in thread
From: James TD Smith @ 2008-10-23 10:27 UTC (permalink / raw)
To: emacs-orgmode
---
lisp/ChangeLog | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
mode change 100755 => 100644 lisp/ChangeLog
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
old mode 100755
new mode 100644
index 0a65adf..e4ffc88
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -74,7 +74,15 @@
* org.el (org-clock-update-time-maybe): Compute negative clock
intervals correctly.
-2008-10-15 James TD Smith <ahktenzero@mohorovi.cc>
+2008-10-16 Carsten Dominik <dominik@science.uva.nl>
+
+ * org.el (org-add-log-setup): Respect
+ `org-log-state-notes-insert-after-drawers'.
+ (org-log-state-notes-insert-after-drawers): New option.
+ (org-todo-trigger-tag-changes): New function.
+ (org-todo): Call `org-todo-trigger-tag-changes'.
+
+2008-10-16 James TD Smith <ahktenzero@mohorovi.cc>
* org.el (org-add-log-setup): Only skip drawers if the are
immediately after the scheduling keywords.
@@ -87,14 +95,6 @@
(org-clock-in): Use org-indent-line-function to indent clock lines.
(org-clock-find-position): Fix indentation of empty clock drawers.
-2008-10-16 Carsten Dominik <dominik@science.uva.nl>
-
- * org.el (org-add-log-setup): Respect
- `org-log-state-notes-insert-after-drawers'.
- (org-log-state-notes-insert-after-drawers): New option.
- (org-todo-trigger-tag-changes): New function.
- (org-todo): Call `org-todo-trigger-tag-changes'.
-
2008-10-15 Carsten Dominik <dominik@science.uva.nl>
* org-publish.el (org-publish-org-to): Handle case when
@@ -178,7 +178,7 @@
* org-clock.el (org-clock-heading-for-remember): New variable.
(org-clock-in): Set `org-clock-heading-for-remember'.
-2008-10-01 James TD Smith <ahktenzero@mohorovi.cc>
+2008-10-01 James TD Smith <ahktenzero@mohorovi.cc>
* org-remember.el (org-remember-apply-template): Add new
expansions: %k, %K for currently clocked task and a link to the
@@ -287,7 +287,7 @@
* org-export-latex.el (org-export-latex-keywords-maybe): Bug fix.
-2008-09-22 James TA Smith <ahktenzero@mohorovi.cc>
+2008-09-22 James TD Smith <ahktenzero@mohorovi.cc>
* org-plot.el (org-plot/gnuplot): Make tables starting with a
hline work correctly.
--
1.5.6.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/3] Add clock resuming.
2008-10-23 10:27 ` [PATCH 1/3] Fix some typos and duplication in the ChangeLog James TD Smith
@ 2008-10-23 10:27 ` James TD Smith
2008-10-23 10:27 ` James TD Smith
2008-10-23 10:28 ` [PATCH 3/3] Add clock persistence James TD Smith
2008-10-24 4:55 ` [PATCH 1/3] Fix some typos and duplication in the ChangeLog Carsten Dominik
1 sibling, 2 replies; 17+ messages in thread
From: James TD Smith @ 2008-10-23 10:27 UTC (permalink / raw)
To: emacs-orgmode
If the option `org-clock-resume' is t, and the first clock line in an entry is is
open, clocking into that task resumes the clock from that time.
---
lisp/ChangeLog | 8 ++++++++
lisp/org-clock.el | 28 +++++++++++++++++++++-------
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e4ffc88..438296d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,6 +3,14 @@
* org.el (org-insert-todo-heading): Fix bug with force-heading
argument.
+2008-10-23 James TD Smith <ahktenzero@mohorovi.cc>
+
+ * org-clock.el (org-clock-in-resume): Add a custom option to
+ toggle starting the clock from an open clock line.
+ (org-clock-in): When clocking in to an entry, if
+ `org-clock-in-resume' is set, check if the first clock line is
+ open and if so, start the clock from the time in the clock line.
+
2008-10-22 Carsten Dominik <dominik@science.uva.nl>
* org-exp.el (org-export-as-ascii): Handle the case that we are
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index da86b0d..40272d4 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -95,6 +95,12 @@ The function is called with point at the beginning of the headline."
:group 'org-clock
:type 'integer)
+(defcustom org-clock-in-resume nil
+ "If non-nil, when clocking into a task with a clock entry which
+has not been closed, resume the clock from that point"
+ :group 'org-clock
+ :type 'boolean)
+
;;; The clock for measuring work time.
(defvar org-mode-line-string "")
@@ -291,12 +297,21 @@ the clocking selection, associated with the letter `d'."
(t "???")))
(setq org-clock-heading (org-propertize org-clock-heading 'face nil))
(org-clock-find-position)
-
- (insert "\n") (backward-char 1)
- (org-indent-line-function)
- (insert org-clock-string " ")
- (setq org-clock-start-time (current-time))
- (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
+ (if (and org-clock-in-resume
+ (looking-at (concat "^[ \\t]* " org-clock-string
+ " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
+ " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\]$")))
+ (progn (message "Matched %s" (match-string 1))
+ (setq ts (concat "[" (match-string 1) "]"))
+ (goto-char (match-end 1))
+ (setq org-clock-start-time
+ (apply 'encode-time (org-parse-time-string (match-string 1)))))
+ (progn
+ (insert "\n") (backward-char 1)
+ (org-indent-line-function)
+ (insert org-clock-string " ")
+ (setq org-clock-start-time (current-time))
+ (setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive))))
(move-marker org-clock-marker (point) (buffer-base-buffer))
(or global-mode-string (setq global-mode-string '("")))
(or (memq 'org-mode-line-string global-mode-string)
@@ -962,7 +977,6 @@ the currently selected interval size."
(re-search-forward "#\\+END:")
(end-of-line 0))))
-
(defun org-clocktable-add-file (file table)
(if table
(let ((lines (org-split-string table "\n"))
--
1.5.6.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/3] Add clock resuming.
2008-10-23 10:27 ` [PATCH 2/3] Add clock resuming James TD Smith
@ 2008-10-23 10:27 ` James TD Smith
2008-10-23 10:28 ` [PATCH 3/3] Add clock persistence James TD Smith
1 sibling, 0 replies; 17+ messages in thread
From: James TD Smith @ 2008-10-23 10:27 UTC (permalink / raw)
To: emacs-orgmode
If the option `org-clock-resume' is t, and the first clock line in an entry is is
open, clocking into that task resumes the clock from that time.
---
lisp/ChangeLog | 8 ++++++++
lisp/org-clock.el | 28 +++++++++++++++++++++-------
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e4ffc88..438296d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,6 +3,14 @@
* org.el (org-insert-todo-heading): Fix bug with force-heading
argument.
+2008-10-23 James TD Smith <ahktenzero@mohorovi.cc>
+
+ * org-clock.el (org-clock-in-resume): Add a custom option to
+ toggle starting the clock from an open clock line.
+ (org-clock-in): When clocking in to an entry, if
+ `org-clock-in-resume' is set, check if the first clock line is
+ open and if so, start the clock from the time in the clock line.
+
2008-10-22 Carsten Dominik <dominik@science.uva.nl>
* org-exp.el (org-export-as-ascii): Handle the case that we are
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index da86b0d..40272d4 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -95,6 +95,12 @@ The function is called with point at the beginning of the headline."
:group 'org-clock
:type 'integer)
+(defcustom org-clock-in-resume nil
+ "If non-nil, when clocking into a task with a clock entry which
+has not been closed, resume the clock from that point"
+ :group 'org-clock
+ :type 'boolean)
+
;;; The clock for measuring work time.
(defvar org-mode-line-string "")
@@ -291,12 +297,21 @@ the clocking selection, associated with the letter `d'."
(t "???")))
(setq org-clock-heading (org-propertize org-clock-heading 'face nil))
(org-clock-find-position)
-
- (insert "\n") (backward-char 1)
- (org-indent-line-function)
- (insert org-clock-string " ")
- (setq org-clock-start-time (current-time))
- (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
+ (if (and org-clock-in-resume
+ (looking-at (concat "^[ \\t]* " org-clock-string
+ " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
+ " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\]$")))
+ (progn (message "Matched %s" (match-string 1))
+ (setq ts (concat "[" (match-string 1) "]"))
+ (goto-char (match-end 1))
+ (setq org-clock-start-time
+ (apply 'encode-time (org-parse-time-string (match-string 1)))))
+ (progn
+ (insert "\n") (backward-char 1)
+ (org-indent-line-function)
+ (insert org-clock-string " ")
+ (setq org-clock-start-time (current-time))
+ (setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive))))
(move-marker org-clock-marker (point) (buffer-base-buffer))
(or global-mode-string (setq global-mode-string '("")))
(or (memq 'org-mode-line-string global-mode-string)
@@ -962,7 +977,6 @@ the currently selected interval size."
(re-search-forward "#\\+END:")
(end-of-line 0))))
-
(defun org-clocktable-add-file (file table)
(if table
(let ((lines (org-split-string table "\n"))
--
1.5.6.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/3] Add clock persistence.
2008-10-23 10:27 ` [PATCH 2/3] Add clock resuming James TD Smith
2008-10-23 10:27 ` James TD Smith
@ 2008-10-23 10:28 ` James TD Smith
2008-10-28 7:33 ` Carsten Dominik
1 sibling, 1 reply; 17+ messages in thread
From: James TD Smith @ 2008-10-23 10:28 UTC (permalink / raw)
To: emacs-orgmode
Clock-related data are saved when exiting emacs ands restored when emacs
is restarted. The data saved include the contents of `org-clock-history',
and the running clock, if there is one.
To use this, you will need to add
(require 'org-clock)
(org-clock-persistence-insinuate)
to your .emacs and either add
(setq org-clock-persist t)
(setq org-clock-in-resume t)
or set those options to t in custom.
This patch requires the clock resume patch.
---
lisp/ChangeLog | 16 +++++++++
lisp/org-clock.el | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 438296d..063ae15 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -10,6 +10,22 @@
(org-clock-in): When clocking in to an entry, if
`org-clock-in-resume' is set, check if the first clock line is
open and if so, start the clock from the time in the clock line.
+ (org-clock-persist): Add a custom option to toggle clock
+ persistence.
+ (org-clock-persist-query-save): Add a custom option to toggle
+ asking the user if they want to save the running clock when
+ exiting.
+ (org-clock-persist-query-resume): Add a custom option to toggle
+ asking the user if they want to resume the saved clock when Emacs
+ is restarted.
+ (org-clock-save): Add a function to save clock data.
+ This includes the contents of `org-clock-history' and the buffer
+ and position of the currently clocked task, if any.
+ (org-clock-load): Add a function to load clock data.
+ This populates `org-clock-history', and resumes the saved clocked
+ task if there is one.
+ (org-clock-persistence-insinuate): Add a method to set up the
+ hooks for clock persistence.
2008-10-22 Carsten Dominik <dominik@science.uva.nl>
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 40272d4..90b2992 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -101,6 +101,28 @@ has not been closed, resume the clock from that point"
:group 'org-clock
:type 'boolean)
+(defcustom org-clock-persist nil
+ "When non-nil, save the running clock when emacs is closed, and
+ resume it next time emacs is started."
+ :group 'org-clock
+ :type 'boolean)
+
+(defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el"
+ "File to save clock data to"
+ :group 'org-clock
+ :type 'string)
+
+(defcustom org-clock-persist-query-save nil
+ "When non-nil, ask before saving the current clock on exit"
+ :group 'org-clock
+ :type 'boolean)
+
+(defcustom org-clock-persist-query-resume t
+ "When non-nil, ask before resuming any stored clock during
+load."
+ :group 'org-clock
+ :type 'boolean)
+
;;; The clock for measuring work time.
(defvar org-mode-line-string "")
@@ -989,6 +1011,74 @@ the currently selected interval size."
lines)
"\n"))))
+(defun org-clock-save ()
+ "Persist various clock-related data to disk"
+ (with-current-buffer (find-file (expand-file-name org-clock-persist-file))
+ (progn (delete-region (point-min) (point-max))
+ ;;Store clock
+ (insert (format ";; org-persist.el - %s at %s\n" system-name (time-stamp-string)))
+ (if (and org-clock-persist (marker-buffer org-clock-marker)
+ (or (not org-clock-persist-query-save)
+ (y-or-n-p (concat "Save current clock ("
+ (substring-no-properties org-clock-heading)
+ ")"))))
+ (insert "(setq resume-clock '(\""
+ (buffer-file-name (marker-buffer org-clock-marker))
+ "\" . " (int-to-string (marker-position org-clock-marker))
+ "))\n"))
+ ;;Store clocked task history. Tasks are stored reversed to make
+ ;;reading simpler
+ (if org-clock-history
+ (insert "(setq stored-clock-history '("
+ (mapconcat
+ (lambda (m)
+ (when (marker-buffer m)
+ (concat "(\"" (buffer-file-name (marker-buffer m))
+ "\" . " (int-to-string (marker-position m))
+ ")")))
+ (reverse org-clock-history) " ") "))\n"))
+ (save-buffer)
+ (kill-buffer (current-buffer)))))
+
+(defvar org-clock-loaded nil)
+
+(defun org-clock-load ()
+ "Load various clock-related data from disk, optionally resuming
+a stored clock"
+ (if (not org-clock-loaded)
+ (let ((filename (expand-file-name org-clock-persist-file))
+ (org-clock-in-resume t))
+ (if (file-readable-p filename)
+ (progn
+ (message "%s" "Restoring clock data")
+ (setq org-clock-loaded t)
+ (load-file filename)
+ ;; load history
+ (if (boundp 'stored-clock-history)
+ (save-window-excursion
+ (mapc (lambda (task)
+ (org-clock-history-push (cdr task)
+ (find-file (car task))))
+ stored-clock-history)))
+ ;; resume clock
+ (if (and (boundp 'resume-clock) org-clock-persist
+ (or (not org-clock-persist-query-resume)
+ (y-or-n-p "Resume clock ("
+ (with-current-buffer (find-file (car resume-clock))
+ (progn (goto-char (cdr resume-clock))
+ (looking-at org-complex-heading-regexp)
+ (match-string 4))) ")")))
+ (with-current-buffer (find-file (car resume-clock))
+ (progn (goto-char (cdr resume-clock))
+ (org-clock-in)))))
+ (message "Not restoring clock data; %s not found"
+ org-clock-persist-file)))))
+
+(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))
+
(provide 'org-clock)
;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
--
1.5.6.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 1/3] Fix some typos and duplication in the ChangeLog
2008-10-23 10:27 ` [PATCH 1/3] Fix some typos and duplication in the ChangeLog James TD Smith
2008-10-23 10:27 ` [PATCH 2/3] Add clock resuming James TD Smith
@ 2008-10-24 4:55 ` Carsten Dominik
1 sibling, 0 replies; 17+ messages in thread
From: Carsten Dominik @ 2008-10-24 4:55 UTC (permalink / raw)
To: James TD Smith; +Cc: emacs-orgmode
applied, thanks.
- Carsten
On Oct 23, 2008, at 12:27 PM, James TD Smith wrote:
> ---
> lisp/ChangeLog | 22 +++++++++++-----------
> 1 files changed, 11 insertions(+), 11 deletions(-)
> mode change 100755 => 100644 lisp/ChangeLog
>
> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> old mode 100755
> new mode 100644
> index 0a65adf..e4ffc88
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -74,7 +74,15 @@
> * org.el (org-clock-update-time-maybe): Compute negative clock
> intervals correctly.
>
> -2008-10-15 James TD Smith <ahktenzero@mohorovi.cc>
> +2008-10-16 Carsten Dominik <dominik@science.uva.nl>
> +
> + * org.el (org-add-log-setup): Respect
> + `org-log-state-notes-insert-after-drawers'.
> + (org-log-state-notes-insert-after-drawers): New option.
> + (org-todo-trigger-tag-changes): New function.
> + (org-todo): Call `org-todo-trigger-tag-changes'.
> +
> +2008-10-16 James TD Smith <ahktenzero@mohorovi.cc>
>
> * org.el (org-add-log-setup): Only skip drawers if the are
> immediately after the scheduling keywords.
> @@ -87,14 +95,6 @@
> (org-clock-in): Use org-indent-line-function to indent clock lines.
> (org-clock-find-position): Fix indentation of empty clock drawers.
>
> -2008-10-16 Carsten Dominik <dominik@science.uva.nl>
> -
> - * org.el (org-add-log-setup): Respect
> - `org-log-state-notes-insert-after-drawers'.
> - (org-log-state-notes-insert-after-drawers): New option.
> - (org-todo-trigger-tag-changes): New function.
> - (org-todo): Call `org-todo-trigger-tag-changes'.
> -
> 2008-10-15 Carsten Dominik <dominik@science.uva.nl>
>
> * org-publish.el (org-publish-org-to): Handle case when
> @@ -178,7 +178,7 @@
> * org-clock.el (org-clock-heading-for-remember): New variable.
> (org-clock-in): Set `org-clock-heading-for-remember'.
>
> -2008-10-01 James TD Smith <ahktenzero@mohorovi.cc>
> +2008-10-01 James TD Smith <ahktenzero@mohorovi.cc>
>
> * org-remember.el (org-remember-apply-template): Add new
> expansions: %k, %K for currently clocked task and a link to the
> @@ -287,7 +287,7 @@
>
> * org-export-latex.el (org-export-latex-keywords-maybe): Bug fix.
>
> -2008-09-22 James TA Smith <ahktenzero@mohorovi.cc>
> +2008-09-22 James TD Smith <ahktenzero@mohorovi.cc>
>
> * org-plot.el (org-plot/gnuplot): Make tables starting with a
> hline work correctly.
> --
> 1.5.6.5
>
>
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] Add clock persistence.
2008-10-23 10:28 ` [PATCH 3/3] Add clock persistence James TD Smith
@ 2008-10-28 7:33 ` Carsten Dominik
2008-10-28 11:10 ` Helge Gudmundsen
0 siblings, 1 reply; 17+ messages in thread
From: Carsten Dominik @ 2008-10-28 7:33 UTC (permalink / raw)
To: James TD Smith; +Cc: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 6360 bytes --]
Hi,
I have now applied these patches and put some initial documentation
into http://orgmode.org/Changes.html.
Since I have not yet tested this myself, I would he glad if some of
you clocking people could test it and report.
Thanks.
- Carsten
On Oct 23, 2008, at 12:28 PM, James TD Smith wrote:
> Clock-related data are saved when exiting emacs ands restored when
> emacs
> is restarted. The data saved include the contents of `org-clock-
> history',
> and the running clock, if there is one.
>
> To use this, you will need to add
>
> (require 'org-clock)
> (org-clock-persistence-insinuate)
>
> to your .emacs and either add
>
> (setq org-clock-persist t)
> (setq org-clock-in-resume t)
>
> or set those options to t in custom.
>
> This patch requires the clock resume patch.
> ---
> lisp/ChangeLog | 16 +++++++++
> lisp/org-clock.el | 90 ++++++++++++++++++++++++++++++++++++++++++++
> +++++++++
> 2 files changed, 106 insertions(+), 0 deletions(-)
>
> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> index 438296d..063ae15 100644
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -10,6 +10,22 @@
> (org-clock-in): When clocking in to an entry, if
> `org-clock-in-resume' is set, check if the first clock line is
> open and if so, start the clock from the time in the clock line.
> + (org-clock-persist): Add a custom option to toggle clock
> + persistence.
> + (org-clock-persist-query-save): Add a custom option to toggle
> + asking the user if they want to save the running clock when
> + exiting.
> + (org-clock-persist-query-resume): Add a custom option to toggle
> + asking the user if they want to resume the saved clock when Emacs
> + is restarted.
> + (org-clock-save): Add a function to save clock data.
> + This includes the contents of `org-clock-history' and the buffer
> + and position of the currently clocked task, if any.
> + (org-clock-load): Add a function to load clock data.
> + This populates `org-clock-history', and resumes the saved clocked
> + task if there is one.
> + (org-clock-persistence-insinuate): Add a method to set up the
> + hooks for clock persistence.
>
> 2008-10-22 Carsten Dominik <dominik@science.uva.nl>
>
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 40272d4..90b2992 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -101,6 +101,28 @@ has not been closed, resume the clock from that
> point"
> :group 'org-clock
> :type 'boolean)
>
> +(defcustom org-clock-persist nil
> + "When non-nil, save the running clock when emacs is closed, and
> + resume it next time emacs is started."
> + :group 'org-clock
> + :type 'boolean)
> +
> +(defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el"
> + "File to save clock data to"
> + :group 'org-clock
> + :type 'string)
> +
> +(defcustom org-clock-persist-query-save nil
> + "When non-nil, ask before saving the current clock on exit"
> + :group 'org-clock
> + :type 'boolean)
> +
> +(defcustom org-clock-persist-query-resume t
> + "When non-nil, ask before resuming any stored clock during
> +load."
> + :group 'org-clock
> + :type 'boolean)
> +
> ;;; The clock for measuring work time.
>
> (defvar org-mode-line-string "")
> @@ -989,6 +1011,74 @@ the currently selected interval size."
> lines)
> "\n"))))
>
> +(defun org-clock-save ()
> + "Persist various clock-related data to disk"
> + (with-current-buffer (find-file (expand-file-name org-clock-
> persist-file))
> + (progn (delete-region (point-min) (point-max))
> + ;;Store clock
> + (insert (format ";; org-persist.el - %s at %s\n" system-name
> (time-stamp-string)))
> + (if (and org-clock-persist (marker-buffer org-clock-marker)
> + (or (not org-clock-persist-query-save)
> + (y-or-n-p (concat "Save current clock ("
> + (substring-no-properties org-clock-heading)
> + ")"))))
> + (insert "(setq resume-clock '(\""
> + (buffer-file-name (marker-buffer org-clock-marker))
> + "\" . " (int-to-string (marker-position org-clock-marker))
> + "))\n"))
> + ;;Store clocked task history. Tasks are stored reversed to make
> + ;;reading simpler
> + (if org-clock-history
> + (insert "(setq stored-clock-history '("
> + (mapconcat
> + (lambda (m)
> + (when (marker-buffer m)
> + (concat "(\"" (buffer-file-name (marker-buffer m))
> + "\" . " (int-to-string (marker-position m))
> + ")")))
> + (reverse org-clock-history) " ") "))\n"))
> + (save-buffer)
> + (kill-buffer (current-buffer)))))
> +
> +(defvar org-clock-loaded nil)
> +
> +(defun org-clock-load ()
> + "Load various clock-related data from disk, optionally resuming
> +a stored clock"
> + (if (not org-clock-loaded)
> + (let ((filename (expand-file-name org-clock-persist-file))
> + (org-clock-in-resume t))
> + (if (file-readable-p filename)
> + (progn
> + (message "%s" "Restoring clock data")
> + (setq org-clock-loaded t)
> + (load-file filename)
> + ;; load history
> + (if (boundp 'stored-clock-history)
> + (save-window-excursion
> + (mapc (lambda (task)
> + (org-clock-history-push (cdr task)
> + (find-file (car task))))
> + stored-clock-history)))
> + ;; resume clock
> + (if (and (boundp 'resume-clock) org-clock-persist
> + (or (not org-clock-persist-query-resume)
> + (y-or-n-p "Resume clock ("
> + (with-current-buffer (find-file (car resume-clock))
> + (progn (goto-char (cdr resume-clock))
> + (looking-at org-complex-heading-regexp)
> + (match-string 4))) ")")))
> + (with-current-buffer (find-file (car resume-clock))
> + (progn (goto-char (cdr resume-clock))
> + (org-clock-in)))))
> + (message "Not restoring clock data; %s not found"
> + org-clock-persist-file)))))
> +
> +(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))
> +
> (provide 'org-clock)
>
> ;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
> --
> 1.5.6.5
>
>
>
> _______________________________________________
> 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
[-- Attachment #1.2: Type: text/html, Size: 16157 bytes --]
[-- Attachment #2: Type: text/plain, Size: 204 bytes --]
_______________________________________________
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] Add clock persistence.
2008-10-28 7:33 ` Carsten Dominik
@ 2008-10-28 11:10 ` Helge Gudmundsen
0 siblings, 0 replies; 17+ messages in thread
From: Helge Gudmundsen @ 2008-10-28 11:10 UTC (permalink / raw)
To: emacs-orgmode
For my (admittedly simple) test cases, so far it looks good. Thanks.
--
helge
On Tue, Oct 28, 2008 at 7:33 AM, Carsten Dominik <dominik@uva.nl> wrote:
> Hi,
> I have now applied these patches and put some initial documentation into
> http://orgmode.org/Changes.html.
> Since I have not yet tested this myself, I would he glad if some of you
> clocking people could test it and report.
> Thanks.
> - Carsten
> On Oct 23, 2008, at 12:28 PM, James TD Smith wrote:
>
> Clock-related data are saved when exiting emacs ands restored when emacs
> is restarted. The data saved include the contents of `org-clock-history',
> and the running clock, if there is one.
>
> To use this, you will need to add
>
> (require 'org-clock)
> (org-clock-persistence-insinuate)
>
> to your .emacs and either add
>
> (setq org-clock-persist t)
> (setq org-clock-in-resume t)
>
> or set those options to t in custom.
>
> This patch requires the clock resume patch.
> ---
> lisp/ChangeLog | 16 +++++++++
> lisp/org-clock.el | 90
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 106 insertions(+), 0 deletions(-)
>
> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> index 438296d..063ae15 100644
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -10,6 +10,22 @@
> (org-clock-in): When clocking in to an entry, if
> `org-clock-in-resume' is set, check if the first clock line is
> open and if so, start the clock from the time in the clock line.
> + (org-clock-persist): Add a custom option to toggle clock
> + persistence.
> + (org-clock-persist-query-save): Add a custom option to toggle
> + asking the user if they want to save the running clock when
> + exiting.
> + (org-clock-persist-query-resume): Add a custom option to toggle
> + asking the user if they want to resume the saved clock when Emacs
> + is restarted.
> + (org-clock-save): Add a function to save clock data.
> + This includes the contents of `org-clock-history' and the buffer
> + and position of the currently clocked task, if any.
> + (org-clock-load): Add a function to load clock data.
> + This populates `org-clock-history', and resumes the saved clocked
> + task if there is one.
> + (org-clock-persistence-insinuate): Add a method to set up the
> + hooks for clock persistence.
>
> 2008-10-22 Carsten Dominik <dominik@science.uva.nl>
>
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 40272d4..90b2992 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -101,6 +101,28 @@ has not been closed, resume the clock from that point"
> :group 'org-clock
> :type 'boolean)
>
> +(defcustom org-clock-persist nil
> + "When non-nil, save the running clock when emacs is closed, and
> + resume it next time emacs is started."
> + :group 'org-clock
> + :type 'boolean)
> +
> +(defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el"
> + "File to save clock data to"
> + :group 'org-clock
> + :type 'string)
> +
> +(defcustom org-clock-persist-query-save nil
> + "When non-nil, ask before saving the current clock on exit"
> + :group 'org-clock
> + :type 'boolean)
> +
> +(defcustom org-clock-persist-query-resume t
> + "When non-nil, ask before resuming any stored clock during
> +load."
> + :group 'org-clock
> + :type 'boolean)
> +
> ;;; The clock for measuring work time.
>
> (defvar org-mode-line-string "")
> @@ -989,6 +1011,74 @@ the currently selected interval size."
> lines)
> "\n"))))
>
> +(defun org-clock-save ()
> + "Persist various clock-related data to disk"
> + (with-current-buffer (find-file (expand-file-name
> org-clock-persist-file))
> + (progn (delete-region (point-min) (point-max))
> + ;;Store clock
> + (insert (format ";; org-persist.el - %s at %s\n" system-name
> (time-stamp-string)))
> + (if (and org-clock-persist (marker-buffer org-clock-marker)
> + (or (not org-clock-persist-query-save)
> + (y-or-n-p (concat "Save current clock ("
> + (substring-no-properties org-clock-heading)
> + ")"))))
> + (insert "(setq resume-clock '(\""
> + (buffer-file-name (marker-buffer org-clock-marker))
> + "\" . " (int-to-string (marker-position org-clock-marker))
> + "))\n"))
> + ;;Store clocked task history. Tasks are stored reversed to make
> + ;;reading simpler
> + (if org-clock-history
> + (insert "(setq stored-clock-history '("
> + (mapconcat
> + (lambda (m)
> + (when (marker-buffer m)
> + (concat "(\"" (buffer-file-name (marker-buffer m))
> + "\" . " (int-to-string (marker-position m))
> + ")")))
> + (reverse org-clock-history) " ") "))\n"))
> + (save-buffer)
> + (kill-buffer (current-buffer)))))
> +
> +(defvar org-clock-loaded nil)
> +
> +(defun org-clock-load ()
> + "Load various clock-related data from disk, optionally resuming
> +a stored clock"
> + (if (not org-clock-loaded)
> + (let ((filename (expand-file-name org-clock-persist-file))
> + (org-clock-in-resume t))
> + (if (file-readable-p filename)
> + (progn
> + (message "%s" "Restoring clock data")
> + (setq org-clock-loaded t)
> + (load-file filename)
> + ;; load history
> + (if (boundp 'stored-clock-history)
> + (save-window-excursion
> + (mapc (lambda (task)
> + (org-clock-history-push (cdr task)
> + (find-file (car task))))
> + stored-clock-history)))
> + ;; resume clock
> + (if (and (boundp 'resume-clock) org-clock-persist
> + (or (not org-clock-persist-query-resume)
> + (y-or-n-p "Resume clock ("
> + (with-current-buffer (find-file (car resume-clock))
> + (progn (goto-char (cdr resume-clock))
> + (looking-at org-complex-heading-regexp)
> + (match-string 4))) ")")))
> + (with-current-buffer (find-file (car resume-clock))
> + (progn (goto-char (cdr resume-clock))
> + (org-clock-in)))))
> + (message "Not restoring clock data; %s not found"
> + org-clock-persist-file)))))
> +
> +(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))
> +
> (provide 'org-clock)
>
> ;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
> --
> 1.5.6.5
>
>
>
> _______________________________________________
> 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
>
>
> _______________________________________________
> 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
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2008-10-28 11:11 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-19 16:22 [PATCH] Bugfix in org-add-log-setup James TD Smith
2008-10-19 16:22 ` [PATCH] Allow storing clock status between emacs sessions James TD Smith
2008-10-20 15:42 ` Helge Gudmundsen
2008-10-22 8:45 ` Helge Gudmundsen
2008-10-22 9:18 ` Carsten Dominik
2008-10-22 9:25 ` Helge Gudmundsen
2008-10-22 9:42 ` James TD Smith
2008-10-22 15:23 ` Carsten Dominik
2008-10-23 10:27 ` [PATCH 0/3] Split my clock resume/clock persistence patch James TD Smith
2008-10-23 10:27 ` [PATCH 1/3] Fix some typos and duplication in the ChangeLog James TD Smith
2008-10-23 10:27 ` [PATCH 2/3] Add clock resuming James TD Smith
2008-10-23 10:27 ` James TD Smith
2008-10-23 10:28 ` [PATCH 3/3] Add clock persistence James TD Smith
2008-10-28 7:33 ` Carsten Dominik
2008-10-28 11:10 ` Helge Gudmundsen
2008-10-24 4:55 ` [PATCH 1/3] Fix some typos and duplication in the ChangeLog Carsten Dominik
2008-10-20 5:46 ` [PATCH] Bugfix in org-add-log-setup Carsten Dominik
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).