summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2019-02-14 15:03:37 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2019-02-14 15:03:37 +0100
commit8fc22d464d2bc4a3397516854375b177835d10bb (patch)
tree88b1d36a4a6d7cc57882094dc861a55c8e3ea9b9
parent3abedb8b64b4b139b68082215db11f99a7f78030 (diff)
downloadorg-mode-8fc22d464d2bc4a3397516854375b177835d10bb.tar.gz
Fix `org-clock-out-when-done' in a narrowed buffer
* lisp/org-clock.el (org-clock-out-if-current): Ignore narrowing. * lisp/org.el (org-todo): Call directly previous function instead of relying on a hook. Reported-by: Leo Vivier <leo.vivier@gmail.com> <http://lists.gnu.org/r/emacs-orgmode/2019-02/msg00132.html>
-rw-r--r--lisp/org-clock.el5
-rw-r--r--lisp/org.el2
2 files changed, 3 insertions, 4 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index fe95437..c8de9b6 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1999,16 +1999,13 @@ and is only done if the variable `org-clock-out-when-done' is not nil."
(or (buffer-base-buffer (current-buffer))
(current-buffer)))
(< (point) org-clock-marker)
- (> (save-excursion (outline-next-heading) (point))
+ (> (org-with-wide-buffer (org-entry-end-position))
org-clock-marker))
;; Clock out, but don't accept a logging message for this.
(let ((org-log-note-clock-out nil)
(org-clock-out-switch-to-state nil))
(org-clock-out))))
-(add-hook 'org-after-todo-state-change-hook
- 'org-clock-out-if-current)
-
;;;###autoload
(defun org-clock-get-clocktable (&rest props)
"Get a formatted clocktable with parameters according to PROPS.
diff --git a/lisp/org.el b/lisp/org.el
index bbb05c7..2e69f61 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -131,6 +131,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
(declare-function org-clock-in "org-clock" (&optional select start-time))
(declare-function org-clock-in-last "org-clock" (&optional arg))
(declare-function org-clock-out "org-clock" (&optional switch-to-state fail-quietly at-time))
+(declare-function org-clock-out-if-current "org-clock" ())
(declare-function org-clock-remove-overlays "org-clock" (&optional beg end noremove))
(declare-function org-clock-report "org-clock" (&optional arg))
(declare-function org-clock-sum "org-clock" (&optional tstart tend headline-filter propname))
@@ -12258,6 +12259,7 @@ When called through ELisp, arg is also interpreted in the following way:
(when org-auto-align-tags (org-align-tags))
(when org-provide-todo-statistics
(org-update-parent-todo-statistics))
+ (org-clock-out-if-current)
(run-hooks 'org-after-todo-state-change-hook)
(when (and arg (not (member org-state org-done-keywords)))
(setq head (org-get-todo-sequence-head org-state)))