Function: rst-toc-insert-stn
rst-toc-insert-stn is a byte-compiled function defined in rst.el.gz.
Signature
(rst-toc-insert-stn STN BUF STYLE DEPTH INDENT NUMBERING KEYMAP TGT-STN)
Documentation
In the current buffer at point insert STN in BUF into table of contents.
See rst-toc-insert-tree for STYLE, DEPTH and TGT-STN. INDENT
is the indentation depth to use for STN. NUMBERING is the prefix
numbering for STN. See rst-toc-insert-link for KEYMAP.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
;; FIXME refactoring: Use `rst-Stn-buffer' instead of `buf'.
(defun rst-toc-insert-stn (stn buf style depth indent numbering keymap tgt-stn)
;; testcover: ok.
"In the current buffer at point insert STN in BUF into table of contents.
See `rst-toc-insert-tree' for STYLE, DEPTH and TGT-STN. INDENT
is the indentation depth to use for STN. NUMBERING is the prefix
numbering for STN. See `rst-toc-insert-link' for KEYMAP."
(when (or (not depth) (> depth 0))
(cl-destructuring-bind
(pfx add
&aux (fnd (when (and tgt-stn
(equal (rst-Stn-get-title-beginning stn)
(rst-Stn-get-title-beginning tgt-stn)))
(point))))
(cond
((eq style 'plain)
(list "" rst-toc-indent))
((eq style 'fixed)
(list (concat numbering rst-toc-insert-number-separator)
rst-toc-indent))
((eq style 'aligned)
(list (concat numbering rst-toc-insert-number-separator)
(+ (length numbering)
(length rst-toc-insert-number-separator))))
((eq style 'listed)
(list (format "%c " (car rst-preferred-bullets)) 2)))
;; Indent using spaces so buffer characteristics like `indent-tabs-mode'
;; do not matter.
(rst-toc-insert-link (concat (make-string indent ? ) pfx) stn buf keymap)
(or (rst-toc-insert-children (rst-Stn-children stn) buf style
(when depth
(1- depth))
(+ indent add) numbering keymap tgt-stn)
fnd))))