Function: reftex-toc-newhead-from-alist

reftex-toc-newhead-from-alist is a byte-compiled function defined in reftex-toc.el.gz.

Signature

(reftex-toc-newhead-from-alist NLEVEL HEAD ALIST)

Documentation

Get new heading with level NLEVEL from ALIST.

If there are no such entries, return nil. If there are several different entries with same new level, choose the one with the smallest distance to the association of HEAD in the alist. This makes it possible for promotion to work several sets of headings, if these sets are sorted blocks in the alist.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-toc.el.gz
(defun reftex-toc-newhead-from-alist (nlevel head alist)
  "Get new heading with level NLEVEL from ALIST.
If there are no such entries, return nil.
If there are several different entries with same new level, choose the
one with the smallest distance to the association of HEAD in the alist.
This makes it possible for promotion to work several sets of headings,
if these sets are sorted blocks in the alist."
  (let* ((al alist)
         (ass (assoc head al))
         (pos (length (memq ass al)))
         dist (mindist 1000) newhead)
    (while al
      (if (equal (cdar al) nlevel)
          (progn
            (setq dist (abs (- (length al) pos)))
            (if (< dist mindist)
                (setq newhead (car (car al))
                      mindist dist))))
      (setq al (cdr al)))
    newhead))