Function: rst-toc

rst-toc is an interactive and byte-compiled function defined in rst.el.gz.

Signature

(rst-toc)

Documentation

Display a table of contents for current buffer.

Displays all section titles found in the current buffer in a hierarchical list. The resulting buffer can be navigated, and selecting a section title moves the cursor to that section.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
(defun rst-toc ()
  ;; testcover: ok.
  "Display a table of contents for current buffer.
Displays all section titles found in the current buffer in a
hierarchical list.  The resulting buffer can be navigated, and
selecting a section title moves the cursor to that section."
  (interactive)
  (rst-reset-section-caches)
  (let* ((wincfg (list (current-window-configuration) (point-marker)))
         (sectree (rst-all-stn))
         (target-stn (rst-stn-containing-point sectree))
	 (target-buf (current-buffer))
         (buf (get-buffer-create rst-toc-buffer-name))
	 target-pos)
    (with-current-buffer buf
      (let ((inhibit-read-only t))
        (rst-toc-mode)
        (delete-region (point-min) (point-max))
	;; FIXME: Could use a customizable style.
        (setq target-pos (rst-toc-insert-tree
			  sectree target-buf 'plain nil nil target-stn))))
    (display-buffer buf)
    (pop-to-buffer buf)
    (setq rst-toc-mode-return-wincfg wincfg)
    (goto-char (or target-pos (point-min)))))