Function: reftex-goto-label

reftex-goto-label is an autoloaded, interactive and byte-compiled function defined in reftex-ref.el.gz.

Signature

(reftex-goto-label &optional OTHER-WINDOW)

Documentation

Prompt for a label (with completion) and jump to the location of this label.

Optional prefix argument OTHER-WINDOW goes to the label in another window.

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-ref.el.gz
;;;###autoload
(defun reftex-goto-label (&optional other-window)
  "Prompt for a label (with completion) and jump to the location of this label.
Optional prefix argument OTHER-WINDOW goes to the label in another window."
  (interactive "P")
  (reftex-access-scan-info)
  (let* ((wcfg (current-window-configuration))
         (docstruct (symbol-value reftex-docstruct-symbol))
	 ;; If point is inside a \ref{} or \pageref{}, use that as
	 ;; default value.
	 (default (when (looking-back "\\\\\\(?:page\\)?ref{[-a-zA-Z0-9_*.:]*"
                                      (line-beginning-position))
		    (reftex-this-word "-a-zA-Z0-9_*.:")))
         (label (completing-read (format-prompt "Label" default)
				 docstruct
                                 (lambda (x) (stringp (car x))) t nil nil
				 default))
         (selection (assoc label docstruct))
         (where (progn
                  (reftex-show-label-location selection t nil 'stay)
                  (point-marker))))
    (unless other-window
      (set-window-configuration wcfg)
      (switch-to-buffer (marker-buffer where))
      (goto-char where))
    (reftex-unhighlight 0)))