Skip to content

Commit

Permalink
org-log-beginning: Fix edge case when we create logbook at eob
Browse files Browse the repository at this point in the history
* lisp/org.el (org-log-beginning): Fix edge case when current headline
is the last headline in the buffer and does not have a final newline.

Fixes https://orgmode.org/list/m21qvi8er5.fsf@ntnu.no
  • Loading branch information
yantar92 committed Sep 13, 2022
1 parent 8ec328e commit f8d740f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lisp/org.el
Original file line number Diff line number Diff line change
Expand Up @@ -10296,12 +10296,16 @@ narrowing."
(throw 'exit nil))))
;; No drawer found. Create one, if permitted.
(when create
;; Unless current heading is the last heading in buffer
;; and does not have a newline, `org-end-of-meta-data'
;; should move us somewhere below the heading.
;; Avoid situation when we insert drawer right before
;; first "*". Otherwise, if the previous heading is
;; folded, we are inserting after visible newline at
;; the end of the fold, thus breaking the fold
;; continuity.
(when (org-at-heading-p) (backward-char))
(unless (eobp)
(when (org-at-heading-p) (backward-char)))
(org-fold-core-ignore-modifications
(unless (bolp) (insert-and-inherit "\n"))
(let ((beg (point)))
Expand Down

0 comments on commit f8d740f

Please sign in to comment.