Function: outline-cycle-buffer
outline-cycle-buffer is an interactive and byte-compiled function
defined in outline.el.gz.
Signature
(outline-cycle-buffer &optional LEVEL)
Documentation
Cycle visibility state of the body lines of the whole buffer.
This cycles the visibility of all the subheadings and bodies of all
the heading lines in the buffer. It cycles them between hide all,
headings only and show all.
Hide all means hide all the buffer's subheadings and their bodies.
Headings only means show all the subheadings, but not their bodies.
Show all means show all the buffer's subheadings and their bodies.
With a prefix argument, show headings up to that LEVEL.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/outline.el.gz
(defun outline-cycle-buffer (&optional level)
"Cycle visibility state of the body lines of the whole buffer.
This cycles the visibility of all the subheadings and bodies of all
the heading lines in the buffer. It cycles them between `hide all',
`headings only' and `show all'.
`Hide all' means hide all the buffer's subheadings and their bodies.
`Headings only' means show all the subheadings, but not their bodies.
`Show all' means show all the buffer's subheadings and their bodies.
With a prefix argument, show headings up to that LEVEL."
(interactive (list (when current-prefix-arg
(prefix-numeric-value current-prefix-arg))))
(let (top-level)
(save-excursion
(goto-char (point-min))
(while (not (or (eq top-level 1) (eobp)))
(when-let* ((level (and (outline-on-heading-p t)
(funcall outline-level))))
(when (< level (or top-level most-positive-fixnum))
(setq top-level (max level 1))))
(outline-next-heading)))
(cond
(level
(outline-hide-sublevels level)
(setq outline--cycle-buffer-state 'all-heading)
(message "All headings up to level %s" level))
((and (eq outline--cycle-buffer-state 'show-all)
top-level)
(outline-hide-sublevels top-level)
(setq outline--cycle-buffer-state 'top-level)
(message "Top level headings"))
((or (eq outline--cycle-buffer-state 'show-all)
(eq outline--cycle-buffer-state 'top-level))
(outline-show-all)
(outline-hide-region-body (point-min) (point-max))
(setq outline--cycle-buffer-state 'all-heading)
(message "All headings"))
(t
(outline-show-all)
(setq outline--cycle-buffer-state 'show-all)
(message "Show all")))))