org-tree-to-indirect-buffer: Fix when last headline is empty at point-max

* lisp/org.el (org-tree-to-indirect-buffer): Consider scenario when
`org-end-of-subtree' with 't second arg moves to `point-max' at the
end of an empty headline.  We do not need to move back the point then.

Fixes https://orgmode.org/list/CA+AFVDUF3RzA-mnoAp8yFv-bppoYJfJo=Wa8qmNQhV-tfHHB+w@mail.gmail.com
This commit is contained in:
Ihor Radchenko 2021-12-16 20:55:08 +08:00
parent 9ca3bc3730
commit 7ec9e37117
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -6905,7 +6905,7 @@ frame is not changed."
(setq beg (point)
heading (org-get-heading 'no-tags))
(org-end-of-subtree t t)
(when (org-at-heading-p) (backward-char 1))
(when (and (not (eobp)) (org-at-heading-p)) (backward-char 1))
(setq end (point)))
(when (and (buffer-live-p org-last-indirect-buffer)
(not (eq org-indirect-buffer-display 'new-frame))