diff --git a/lisp/org-clock.el b/lisp/org-clock.el index ce26a98b4..87bba4bc0 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1590,18 +1590,19 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." m (floor (/ s 60)) s (- s (* 60 s))) (insert " => " (format "%2d:%02d" h m)) - (when (setq remove (and org-clock-out-remove-zero-time-clocks - (= (+ h m) 0))) - (beginning-of-line 1) - (delete-region (point) (point-at-eol)) - (and (looking-at "\n") (> (point-max) (1+ (point))) - (delete-char 1))) (move-marker org-clock-marker nil) (move-marker org-clock-hd-marker nil) - (when 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. However, do not add + ;; a note associated to the CLOCK line in this case. + (cond ((and org-clock-out-remove-zero-time-clocks + (= (+ h m) 0)) + (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")))) (when org-clock-mode-line-timer (cancel-timer org-clock-mode-line-timer) (setq org-clock-mode-line-timer nil)) diff --git a/lisp/org.el b/lisp/org.el index e93000418..e7d6b571b 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13815,7 +13815,10 @@ EXTRA is additional text that will be inserted into the notes buffer." ;; Find location for the new note. (goto-char org-log-note-marker) (set-marker org-log-note-marker nil) - (goto-char (org-log-beginning t)) + ;; Note associated to a clock is to be located right after + ;; the clock. Do not move point. + (unless (eq org-log-note-purpose 'clock-out) + (goto-char (org-log-beginning t))) ;; Make sure point is at the beginning of an empty line. (cond ((not (bolp)) (let ((inhibit-read-only t)) (insert "\n"))) ((looking-at "[ \t]*\\S-") (save-excursion (insert "\n"))))