Function: reftex-display-index

reftex-display-index is an autoloaded, interactive and byte-compiled function defined in reftex-index.el.gz.

Signature

(reftex-display-index &optional TAG OVERRIDING-RESTRICTION REDO &rest LOCATIONS)

Documentation

Display a buffer with an index compiled from the current document.

When the document has multiple indices, first prompts for the correct one. When index support is turned off, offer to turn it on. With one or two C-u (universal-argument) prefixes, rescan document first. With prefix 2, restrict index to current document section. With prefix 3, restrict index to region.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-index.el.gz
;;;###autoload
(defun reftex-display-index (&optional tag overriding-restriction redo
                                       &rest locations)
  "Display a buffer with an index compiled from the current document.
When the document has multiple indices, first prompts for the correct one.
When index support is turned off, offer to turn it on.
With one or two \\[universal-argument] prefixes, rescan document first.
With prefix 2, restrict index to current document section.
With prefix 3, restrict index to region."

  (interactive)

  ;; Ensure access to scanning info and rescan buffer if prefix arg is '(4).
  (let ((current-prefix-arg current-prefix-arg))
    (reftex-ensure-index-support t)
    (reftex-access-scan-info current-prefix-arg))

  (set-marker reftex-index-return-marker (point))
  (setq reftex-last-follow-point 1)

  ;; Determine the correct index to process
  (let* ((docstruct (symbol-value reftex-docstruct-symbol))
         (docstruct-symbol reftex-docstruct-symbol)
         (index-tag (or tag (reftex-index-select-tag)))
         (master (reftex-TeX-master-file))
         (calling-file (reftex--get-buffer-identifier))
         (restriction
          (or overriding-restriction
              (and (not redo)
                   (reftex-get-restriction current-prefix-arg docstruct))))
         (locations
          ;; See if we are on an index macro as initial position
          (or locations
              (let* ((what-macro (reftex-what-macro-safe 1))
                     (macro (car what-macro))
                     (here-I-am (when (member macro reftex-macros-with-index)
                                  (save-excursion
                                    (goto-char (+ (cdr what-macro)
                                                  (length macro)))
                                    (reftex-move-over-touching-args)
                                    (reftex-where-am-I)))))
                (if (eq (car (car here-I-am)) 'index)
                    (list (car here-I-am))))))
         buffer-name)

    (setq buffer-name (reftex-make-index-buffer-name index-tag))

    ;; Goto the buffer and put it into the correct mode

    (when (or restriction current-prefix-arg)
         (reftex-kill-buffer buffer-name))

    (if (get-buffer-window buffer-name)
        (select-window (get-buffer-window buffer-name))
      (switch-to-buffer buffer-name))

    (or (eq major-mode 'reftex-index-mode) (reftex-index-mode))

    ;; If the buffer is currently restricted, empty it to force update.
    (when reftex-index-restriction-data
      (reftex-erase-buffer))
    (setq-local reftex-last-index-file calling-file)
    (setq-local reftex-index-tag index-tag)
    (setq-local reftex-docstruct-symbol docstruct-symbol)
    (if restriction
        (setq reftex-index-restriction-indicator (car restriction)
              reftex-index-restriction-data (cdr restriction))
      (if (not redo)
          (setq reftex-index-restriction-indicator nil
                reftex-index-restriction-data nil)))
    (when (= (buffer-size) 0)
      ;; buffer is empty - fill it
      (message "Building %s buffer..." buffer-name)

      (setq buffer-read-only nil)
      (insert (format
               "INDEX <%s> on %s
Restriction: <%s>
SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan [f]ollow [?]Help
------------------------------------------------------------------------------
"
               index-tag (reftex--abbreviate-name master)
               (if (eq (car (car reftex-index-restriction-data)) 'toc)
                   (nth 2 (car reftex-index-restriction-data))
                 reftex-index-restriction-indicator)))

      (if reftex-use-fonts
          (put-text-property (point-min) (point)
                             'face reftex-index-header-face))
      (cursor-intangible-mode 1)
      (add-text-properties (point-min) (point)
                           '(cursor-intangible t
                             front-sticky (cursor-intangible)
                             rear-nonsticky (cursor-intangible)))

      (reftex-insert-index docstruct index-tag)
      (goto-char (point-min))
      (run-hooks 'reftex-display-copied-context-hook)
      (message "Building %s buffer...done." buffer-name)
      (setq buffer-read-only t))
    (and locations (apply #'reftex-find-start-point (point) locations))
    (if reftex-index-restriction-indicator
        (message "Index restricted: <%s>" reftex-index-restriction-indicator))))