Function: reftex-insert-index
reftex-insert-index is a byte-compiled function defined in
reftex-index.el.gz.
Signature
(reftex-insert-index DOCSTRUCT TAG &optional UPDATE-ONE REMARK)
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/reftex-index.el.gz
(defun reftex-insert-index (docstruct tag &optional update-one remark)
;; Insert an index into the current buffer. Entries are from the
;; DOCSTRUCT.
;; TAG is the subindex to process.
;; UPDATE-ONE: When non-nil, delete the entry at point and replace
;; it with whatever the DOCSTRUCT contains.
;; REMARK can be a note to add to the entry.
(let* ((all docstruct)
(indent " ")
(context reftex-index-include-context)
(context-indent (concat indent " "))
(section-chars (mapcar #'identity reftex-index-section-letters))
(this-section-char 0)
(font (reftex-use-fonts))
(bor (car reftex-index-restriction-data))
(eor (nth 1 reftex-index-restriction-data))
(mouse-face
(if (memq reftex-highlight-selection '(mouse both))
reftex-mouse-selected-face
nil))
(index-face reftex-label-face)
sublist cell from to first-char)
;; Make the sublist and sort it
(when bor
(setq all (or (memq bor all) all)))
(while (setq cell (pop all))
(if (eq cell eor)
(setq all nil)
(and (eq (car cell) 'index)
(equal (nth 1 cell) tag)
(push cell sublist))))
(setq sublist (sort (nreverse sublist)
(lambda (a b) (string< (nth 8 a) (nth 8 b)))))
(when update-one
;; Delete the entry at place
(and (bolp) (forward-char 1))
(delete-region (previous-single-property-change (1+ (point)) :data)
(or (next-single-property-change (point) :data)
(point-max))))
;; Walk through the list and insert all entries
(while (setq cell (pop sublist))
(unless update-one
(setq first-char (upcase (string-to-char (nth 6 cell))))
(when (and (not (equal first-char this-section-char))
(member first-char section-chars))
;; There is a new initial letter, so start a new section
(reftex-index-insert-new-letter first-char font)
(setq section-chars (delete first-char section-chars)
this-section-char first-char))
(when (= this-section-char 0)
(setq this-section-char ?!)
(reftex-index-insert-new-letter this-section-char font)))
(setq from (point))
(insert indent (nth 7 cell))
(when font
(setq to (point))
(put-text-property
(- (point) (length (nth 7 cell))) to
'face index-face)
(goto-char to))
(when (or remark (nth 9 cell))
(and (< (current-column) 40)
;; FIXME: maybe this is too slow?
(insert (make-string (max (- 40 (current-column)) 0) ?\ )))
(and (nth 9 cell) (insert " " (substring (nth 5 cell) (nth 9 cell))))
(and remark (insert " " remark)))
(insert "\n")
(setq to (point))
(when context
(insert context-indent (nth 2 cell) "\n")
(setq to (point)))
(put-text-property from to :data cell)
(when mouse-face
(put-text-property from (1- to)
'mouse-face mouse-face))
(goto-char to))))