org.el: Fix cycling hang when %p is in frame-title-format

* lisp/org.el (org-optimize-window-after-visibility-change): Guard
against calling set-window-start with a nil POS argument.

org-optimize-window-after-visibility-change calls set-window-start
with org-scroll-position-to-restore when it is a repeat call
(i.e. last-command and this-command match).  However,
org-scroll-position-to-restore may not have yet been set yet (e.g. if
org-startup-folded is at its default value of showeverything).

Calling set-window-start appears to generally be a noop, but, for a
reason that I don't understand, it triggers a hang when %p is in
frame-title-format.

Reported-by: Massimo Lauria <massimo.lauria@uniroma1.it>
Ref: https://orgmode.org/list/CAJCFsEEHJXP4nKZpWdzheMM5O0Dq-tT+v0u0FsT+3Q0mi4v10A@mail.gmail.com
This commit is contained in:
Kyle Meyer 2020-12-10 00:40:05 -05:00
parent 2eb5f0741f
commit 4f8ac0a7a3
1 changed files with 2 additions and 1 deletions

View File

@ -6618,7 +6618,8 @@ This function is the default value of the hook `org-cycle-hook'."
(cond
((eq state 'content) nil)
((eq state 'all) nil)
((and (eq state 'folded) (eq last-command this-command))
((and org-scroll-position-to-restore
(eq state 'folded) (eq last-command this-command))
(set-window-start nil org-scroll-position-to-restore))
((eq state 'folded) nil)
((eq state 'children)