org-capture.el: make :immediate-finish cooperate with :clock-in.

* org-capture.el (org-capture-finalize): New argument
clock-out, to tell whether finalizing the capture process
should clock out the running clock.
(org-capture): Use the new argument.
This commit is contained in:
Bastien Guerry 2011-03-06 01:09:51 +01:00
parent 5606a6a941
commit c255f03676
1 changed files with 8 additions and 7 deletions

View File

@ -455,7 +455,7 @@ bypassed."
(org-capture-get :key)
(nth 1 error))))
(if (org-capture-get :immediate-finish)
(org-capture-finalize)
(org-capture-finalize nil t)
(if (and (org-mode-p)
(org-capture-get :clock-in))
(condition-case nil
@ -468,7 +468,6 @@ bypassed."
(error
"Could not start the clock in this capture buffer")))))))))))
(defun org-capture-get-template ()
"Get the template from a file or a function if necessary."
(let ((txt (org-capture-get :template)) file)
@ -487,10 +486,12 @@ bypassed."
(t (setq txt "* Invalid capture template")))
(org-capture-put :template txt)))
(defun org-capture-finalize (&optional stay-with-capture)
(defun org-capture-finalize (&optional stay-with-capture clock-out)
"Finalize the capture process.
With prefix argument STAY-WITH-CAPTURE, jump to the location of the
captured item after finalizing."
captured item after finalizing.
A second optional argument tells whether finalizing the capture
process should clock-out the captured entry."
(interactive "P")
(unless (and org-capture-mode
(buffer-base-buffer (current-buffer)))
@ -503,7 +504,7 @@ captured item after finalizing."
(> org-clock-marker (point-min))
(< org-clock-marker (point-max)))
;; Looks like the clock we started is still running. Clock out.
(let (org-log-note-clock-out) (org-clock-out))
(when clock-out (let (org-log-note-clock-out) (org-clock-out)))
(when (and (org-capture-get :clock-resume 'local)
(markerp (org-capture-get :interrupted-clock 'local))
(buffer-live-p (marker-buffer