[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 8e3e2f6: clock: Prevent "before first headline" err
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 8e3e2f6: clock: Prevent "before first headline" error on clock-out note |
Date: |
Sun, 27 Jun 2021 10:57:11 -0400 (EDT) |
branch: externals/org
commit 8e3e2f667f0b28b85845204b708c3f0aebc9152b
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>
clock: Prevent "before first headline" error on clock-out note
* lisp/org-clock.el (org-clock-out): Possibly create a note at the
very end of the process, when there's no need for point to be on the
correct headline. Also call `org-clock-remove-empty-clock-drawer'
unconditionally instead of putting it in `org-clock-out-hook'.
Reported-by: Dave Dai <wenlong.dai@gmail.com>
<https://yhetil.org/orgmode/87pmwaang6.fsf@HUE.i-did-not-set--mail-host-address--so-tickle-me/»
---
lisp/org-clock.el | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 5480a37..cd930e8 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1676,17 +1676,13 @@ to, overriding the existing value of
`org-clock-out-switch-to-state'."
(insert " => " (format "%2d:%02d" h m))
(move-marker org-clock-marker nil)
(move-marker org-clock-hd-marker nil)
- ;; Possibly remove zero time clocks. However, do not add
- ;; a note associated to the CLOCK line in this case.
- (cond ((and org-clock-out-remove-zero-time-clocks
- (= 0 h m))
- (setq remove t)
- (delete-region (line-beginning-position)
- (line-beginning-position 2)))
- (org-log-note-clock-out
- (org-add-log-setup
- 'clock-out nil nil nil
- (concat "# Task: " (org-get-heading t) "\n\n"))))
+ ;; Possibly remove zero time clocks.
+ (when (and org-clock-out-remove-zero-time-clocks
+ (= 0 h m))
+ (setq remove t)
+ (delete-region (line-beginning-position)
+ (line-beginning-position 2)))
+ (org-clock-remove-empty-clock-drawer)
(when org-clock-mode-line-timer
(cancel-timer org-clock-mode-line-timer)
(setq org-clock-mode-line-timer nil))
@@ -1717,11 +1713,14 @@ to, overriding the existing value of
`org-clock-out-switch-to-state'."
"Clock stopped at %s after %s => LINE REMOVED"
"Clock stopped at %s after %s")
te (org-duration-from-minutes (+ (* 60 h) m)))
- (run-hooks 'org-clock-out-hook)
- (unless (org-clocking-p)
- (setq org-clock-current-task nil)))))))
-
-(add-hook 'org-clock-out-hook #'org-clock-remove-empty-clock-drawer)
+ (unless (org-clocking-p)
+ (setq org-clock-current-task nil))
+ (run-hooks 'org-clock-out-hook)
+ ;; Add a note, but only if we didn't remove the clock line.
+ (when (and org-log-note-clock-out (not remove))
+ (org-add-log-setup
+ 'clock-out nil nil nil
+ (concat "# Task: " (org-get-heading t) "\n\n"))))))))
(defun org-clock-remove-empty-clock-drawer ()
"Remove empty clock drawers in current subtree."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/org 8e3e2f6: clock: Prevent "before first headline" error on clock-out note,
ELPA Syncer <=