Function: reftex-view-cr-ref

reftex-view-cr-ref is a byte-compiled function defined in reftex-dcr.el.gz.

Signature

(reftex-view-cr-ref ARG LABEL HOW)

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-dcr.el.gz
(defun reftex-view-cr-ref (arg label how)
  ;; View crossreference of a ref macro.  HOW can have the values
  ;; nil:         Show in another window.
  ;; echo:        Show one-line info in echo area.
  ;; tmp-window:  Show in small window and arrange for window to disappear.

  ;; Ensure access to scanning info
  (reftex-access-scan-info (or arg current-prefix-arg))

  (if (eq how 'tmp-window)
      ;; Remember the window configuration
      (put 'reftex-auto-view-crossref 'last-window-conf
           (current-window-configuration)))

  (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol)))
         (xr-re (nth 2 xr-data))
         (entry (assoc label (symbol-value reftex-docstruct-symbol)))
         (win (selected-window)) pop-win (pos (point)))

    (if (and (not entry) (stringp label) xr-re (string-match xr-re label))
        ;; Label is defined in external document
        (save-excursion
          (save-match-data
            (set-buffer
             (or (reftex-get-file-buffer-force
                  (cdr (assoc (match-string 1 label) (nth 1
                                                          xr-data))))
                 (error "Problem with external label %s" label))))
          (setq label (substring label (match-end 1)))
          (reftex-access-scan-info)
          (setq entry
                (assoc label (symbol-value reftex-docstruct-symbol)))))
    (if (eq how 'echo)
        ;; Display in echo area
        (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol))
      (let ((window-conf (current-window-configuration)))
        (condition-case nil
            (reftex-show-label-location entry t nil t t)
          (error (set-window-configuration window-conf)
                 (message "ref: Label %s not found" label)
                 (error "ref: Label %s not found" label)))) ;; 2nd is line OK
      (add-hook 'pre-command-hook #'reftex-highlight-shall-die)

      (when (eq how 'tmp-window)
        ;; Resize window and arrange restoration
        (shrink-window (1- (- (window-height) 9)))
        (recenter '(4))
        (add-hook 'pre-command-hook #'reftex-restore-window-conf))
      (setq pop-win (selected-window))
      (select-window win)
      (goto-char pos)
      (when (equal arg 2)
        (select-window pop-win)))))