Function: outline-cycle-buffer

outline-cycle-buffer is an interactive and byte-compiled function defined in outline.el.gz.

Signature

(outline-cycle-buffer)

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.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/outline.el.gz
(defun outline-cycle-buffer ()
  "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."
  (interactive)
  (let (has-top-level)
    (save-excursion
      (goto-char (point-min))
      (while (not (or has-top-level (eobp)))
        (when (outline-on-heading-p t)
          (when (= (funcall outline-level) 1)
            (setq has-top-level t)))
        (outline-next-heading)))
    (cond
     ((and (eq outline--cycle-buffer-state 'show-all)
           has-top-level)
      (outline-hide-sublevels 1)
      (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")))))