summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2011-04-08 18:04:47 +0200
committerBastien Guerry <bzg@altern.org>2011-04-08 18:04:47 +0200
commit8cf35f0ab123af42f4c7be83d2b179114da40d20 (patch)
tree0dbc36ee347d86023b91fa06bbddb901764f6563
parenta0a526bc3e5d1f3ec2339f5a337340632c2069ae (diff)
downloadorg-mode-8cf35f0ab123af42f4c7be83d2b179114da40d20.tar.gz
org-capture.el: Fix bugs about handling the :clock-keep parameter.
* org-capture.el (org-capture-clock-keep): New local variable. (org-capture, org-capture-finalize): Use it and fix a bug when :clock-keep is set to `t'.
-rw-r--r--lisp/org-capture.el38
1 files changed, 20 insertions, 18 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index c9b3b7d..8beea68 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -347,6 +347,9 @@ The remember buffer is still current when this hook runs."
"Local variable holding the plist in a capture buffer.
This is used to store the plist for use when finishing a capture process.
Another such process might have changed the global variable by then.")
+(defvar org-capture-clock-keep nil
+ "Local variable to store the value of the :clock-keep parameter.
+This is needed in case org-capture-finalize is called interactively.")
(defun org-capture-put (&rest stuff)
(while stuff
@@ -447,6 +450,7 @@ bypassed."
(if (get-buffer "*Capture*") (kill-buffer "*Capture*"))
(error "Capture abort: %s" error)))
+ (setq org-capture-clock-keep (org-capture-get :clock-keep))
(if (equal goto 0)
;;insert at point
(org-capture-insert-template-here)
@@ -460,19 +464,19 @@ bypassed."
(error "Capture template `%s': %s"
(org-capture-get :key)
(nth 1 error))))
+ (if (and (org-mode-p)
+ (org-capture-get :clock-in))
+ (condition-case nil
+ (progn
+ (if (org-clock-is-active)
+ (org-capture-put :interrupted-clock
+ (copy-marker org-clock-marker)))
+ (org-clock-in)
+ (org-set-local 'org-capture-clock-was-started t))
+ (error
+ "Could not start the clock in this capture buffer")))
(if (org-capture-get :immediate-finish)
- (org-capture-finalize nil (org-capture-get :clock-keep))
- (if (and (org-mode-p)
- (org-capture-get :clock-in))
- (condition-case nil
- (progn
- (if (org-clock-is-active)
- (org-capture-put :interrupted-clock
- (copy-marker org-clock-marker)))
- (org-clock-in)
- (org-set-local 'org-capture-clock-was-started t))
- (error
- "Could not start the clock in this capture buffer")))))))))))
+ (org-capture-finalize nil)))))))))
(defun org-capture-get-template ()
"Get the template from a file or a function if necessary."
@@ -492,12 +496,10 @@ bypassed."
(t (setq txt "* Invalid capture template")))
(org-capture-put :template txt)))
-(defun org-capture-finalize (&optional stay-with-capture clock-keep)
+(defun org-capture-finalize (&optional stay-with-capture)
"Finalize the capture process.
With prefix argument STAY-WITH-CAPTURE, jump to the location of the
-captured item after finalizing.
-A second optional argument tells whether finalizing the capture
-process should keep the clock running in the filed entry."
+captured item after finalizing."
(interactive "P")
(unless (and org-capture-mode
(buffer-base-buffer (current-buffer)))
@@ -510,8 +512,8 @@ process should keep the clock running in the filed entry."
(> org-clock-marker (point-min))
(< org-clock-marker (point-max)))
;; Looks like the clock we started is still running. Clock out.
- (when (not clock-keep) (let (org-log-note-clock-out) (org-clock-out)))
- (when (and (not clock-keep)
+ (when (not org-capture-clock-keep) (let (org-log-note-clock-out) (org-clock-out)))
+ (when (and (not org-capture-clock-keep)
(org-capture-get :clock-resume 'local)
(markerp (org-capture-get :interrupted-clock 'local))
(buffer-live-p (marker-buffer