forked from mirrors/org-mode
org-clock: Do not assume that clock is always inside capture buffer
* lisp/org-capture.el (org-capture): Store the clock marker in `org-capture-clock-was-started'. (org-capture-clock-was-started): Document that the variable holds clock marker. (org-capture-finalize): Check the stored value of the clock marker when deciding if the currently running clock has been started by capture. Reported-by: Bernt Hansen <bernt@norang.ca> Link: https://orgmode.org/list/878rza7c0w.fsf@localhost
This commit is contained in:
parent
5adde9f3fe
commit
224708323e
|
@ -86,7 +86,7 @@
|
||||||
(defvar org-table-hlines)
|
(defvar org-table-hlines)
|
||||||
|
|
||||||
(defvar org-capture-clock-was-started nil
|
(defvar org-capture-clock-was-started nil
|
||||||
"Internal flag, noting if the clock was started.")
|
"Internal flag, keeping marker to the started clock.")
|
||||||
|
|
||||||
(defvar org-capture-last-stored-marker (make-marker)
|
(defvar org-capture-last-stored-marker (make-marker)
|
||||||
"Marker pointing to the entry most recently stored with `org-capture'.")
|
"Marker pointing to the entry most recently stored with `org-capture'.")
|
||||||
|
@ -719,7 +719,8 @@ of the day at point (if any) or the current HH:MM time."
|
||||||
(org-capture-put :interrupted-clock
|
(org-capture-put :interrupted-clock
|
||||||
(copy-marker org-clock-marker)))
|
(copy-marker org-clock-marker)))
|
||||||
(org-clock-in)
|
(org-clock-in)
|
||||||
(setq-local org-capture-clock-was-started t))
|
(setq-local org-capture-clock-was-started
|
||||||
|
(copy-marker org-clock-marker)))
|
||||||
(error "Could not start the clock in this capture buffer")))
|
(error "Could not start the clock in this capture buffer")))
|
||||||
(when (org-capture-get :immediate-finish)
|
(when (org-capture-get :immediate-finish)
|
||||||
(org-capture-finalize))))))))
|
(org-capture-finalize))))))))
|
||||||
|
@ -760,10 +761,7 @@ captured item after finalizing."
|
||||||
|
|
||||||
;; Did we start the clock in this capture buffer?
|
;; Did we start the clock in this capture buffer?
|
||||||
(when (and org-capture-clock-was-started
|
(when (and org-capture-clock-was-started
|
||||||
org-clock-marker
|
(equal org-clock-marker org-capture-clock-was-started))
|
||||||
(eq (marker-buffer org-clock-marker) (buffer-base-buffer))
|
|
||||||
(>= org-clock-marker (point-min))
|
|
||||||
(< org-clock-marker (point-max)))
|
|
||||||
;; Looks like the clock we started is still running.
|
;; Looks like the clock we started is still running.
|
||||||
(if org-capture-clock-keep
|
(if org-capture-clock-keep
|
||||||
;; User may have completed clocked heading from the template.
|
;; User may have completed clocked heading from the template.
|
||||||
|
|
Loading…
Reference in New Issue