Function: rst-remaining-stn
rst-remaining-stn is a byte-compiled function defined in rst.el.gz.
Signature
(rst-remaining-stn UNPROCESSED EXPECTED)
Documentation
Process the first entry of UNPROCESSED expected to be on level EXPECTED.
UNPROCESSED is the remaining list of (rst-Ttl . LEVEL) entries.
Return (REMAINING . STN) for the first entry of UNPROCESSED.
REMAINING is the list of still unprocessed entries. STN is a
rst-Stn or nil if UNPROCESSED is empty.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
(defun rst-remaining-stn (unprocessed expected)
;; testcover: ok.
"Process the first entry of UNPROCESSED expected to be on level EXPECTED.
UNPROCESSED is the remaining list of (`rst-Ttl' . LEVEL) entries.
Return (REMAINING . STN) for the first entry of UNPROCESSED.
REMAINING is the list of still unprocessed entries. STN is a
`rst-Stn' or nil if UNPROCESSED is empty."
(if (not unprocessed)
(1value
(cons nil nil))
(cl-destructuring-bind
((ttl &rest level) &rest next
&aux fnd children)
unprocessed
(when (= level expected)
;; Consume the current entry and create the current node with it.
(setq fnd ttl)
(setq unprocessed next))
;; Build the child nodes as long as they have deeper level.
(while (and unprocessed (> (cdar unprocessed) expected))
(cl-destructuring-bind (remaining &rest stn)
(rst-remaining-stn unprocessed (1+ expected))
(when stn
(push stn children))
(setq unprocessed remaining)))
(cons unprocessed
(when (or fnd children)
(rst-Stn-new fnd expected (nreverse children)))))))