Function: rst-next-hdr
rst-next-hdr is a byte-compiled function defined in rst.el.gz.
Signature
(rst-next-hdr HDR HIER PREV DOWN)
Documentation
Return the next best rst-Hdr upward from HDR.
Consider existing hierarchy HIER and preferred headers. PREV may
be a previous rst-Hdr which may be taken into account. If DOWN
return the next best rst-Hdr downward instead. Return nil if
HIER is nil.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
t))) ; Normalize return value.
(defun rst-next-hdr (hdr hier prev down)
;; testcover: ok.
"Return the next best `rst-Hdr' upward from HDR.
Consider existing hierarchy HIER and preferred headers. PREV may
be a previous `rst-Hdr' which may be taken into account. If DOWN
return the next best `rst-Hdr' downward instead. Return nil if
HIER is nil."
(let* ((normalized-hier (if down
hier
(reverse hier)))
(fnd (rst-Hdr-member-ado hdr normalized-hier))
(prev-fnd (and prev (rst-Hdr-member-ado prev normalized-hier))))
(or
;; Next entry in existing hierarchy if it exists.
(cadr fnd)
(if fnd
;; If current header is found try introducing a new one from preferred
;; hierarchy.
(rst-new-preferred-hdr hier prev)
;; If not found try using previous header.
(if down
(cadr prev-fnd)
(car prev-fnd)))
;; All failed - rotate by using first from normalized existing hierarchy.
(car normalized-hier))))