Function: org-cycle-optimize-window-after-visibility-change
org-cycle-optimize-window-after-visibility-change is a byte-compiled
function defined in org-cycle.el.gz.
Signature
(org-cycle-optimize-window-after-visibility-change STATE)
Documentation
Adjust the window after a change in outline visibility.
This function is the default value of the hook org-cycle-hook.
Aliases
org-optimize-window-after-visibility-change (obsolete since 9.6)
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-cycle.el.gz
(defun org-cycle-optimize-window-after-visibility-change (state)
"Adjust the window after a change in outline visibility.
This function is the default value of the hook `org-cycle-hook'."
(when (get-buffer-window (current-buffer))
(let ((repeat (eq last-command this-command)))
(unless repeat
(setq org-cycle-scroll-position-to-restore nil))
(cond
((eq state 'content) nil)
((eq state 'all) nil)
((and org-cycle-scroll-position-to-restore repeat
(eq state 'folded))
(set-window-start nil org-cycle-scroll-position-to-restore))
((eq state 'folded) nil)
((eq state 'children)
(setq org-cycle-scroll-position-to-restore (window-start))
(or (org-subtree-end-visible-p) (recenter 1)))
((eq state 'subtree)
(unless repeat
(setq org-cycle-scroll-position-to-restore (window-start)))
(or (org-subtree-end-visible-p) (recenter 1)))))))