Skip to content

Commit 8ec328e

Browse files
committed
org-log-beginning: Fix for headline at eob with no trailing newline
* lisp/org.el (org-log-beginning): Fix edge case when there is a headline at the end of buffer and that headline does not have a trailing newline. Fixes https://orgmode.org/list/m24k0ffjyd.fsf@ntnu.no
1 parent 4fc2c8d commit 8ec328e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lisp/org.el

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10311,12 +10311,17 @@ narrowing."
1031110311
(end-of-line -1))))
1031210312
(t
1031310313
(org-end-of-meta-data org-log-state-notes-insert-after-drawers)
10314-
(skip-chars-forward " \t\n")
10315-
(beginning-of-line)
10316-
(unless org-log-states-order-reversed
10317-
(org-skip-over-state-notes)
10318-
(skip-chars-backward " \t\n")
10319-
(beginning-of-line 2)))))
10314+
(let ((endpos (point)))
10315+
(skip-chars-forward " \t\n")
10316+
(beginning-of-line)
10317+
(unless org-log-states-order-reversed
10318+
(org-skip-over-state-notes)
10319+
(skip-chars-backward " \t\n")
10320+
(beginning-of-line 2))
10321+
;; When current headline is at the end of buffer and does not
10322+
;; end with trailing newline the above can move to the
10323+
;; beginning of the headline.
10324+
(when (< (point) endpos)) (goto-char endpos)))))
1032010325
(if (bolp) (point) (line-beginning-position 2))))
1032110326

1032210327
(defun org-add-log-setup (&optional purpose state prev-state how extra)

0 commit comments

Comments
 (0)