Function: reftex-label-location

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

Signature

(reftex-label-location &optional BOUND)

Documentation

Return the environment or macro which determines the label type at point.

If optional BOUND is an integer, limit backward searches to that point.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-ref.el.gz
;;;###autoload
(defun reftex-label-location (&optional bound)
  "Return the environment or macro which determines the label type at point.
If optional BOUND is an integer, limit backward searches to that point."

  (let* ((loc1 (reftex-what-macro reftex-label-mac-list bound))
         (loc2 (reftex-what-environment reftex-label-env-list bound))
         (loc3 (reftex-what-special-env 1 bound))
         (p1 (or (cdr loc1) 0))
         (p2 (or (cdr loc2) 0))
         (p3 (or (cdr loc3) 0))
         (pmax (max p1 p2 p3)))

    (setq reftex-location-start pmax)
    (cond
     ((= p1 pmax)
      ;; A macro.  Default context after macro name.
      (setq reftex-default-context-position (+ p1 (length (car loc1))))
      (or (car loc1) "section"))
     ((= p2 pmax)
      ;; An environment.  Default context after \begin{name}.
      (setq reftex-default-context-position (+ p2 8 (length (car loc2))))
      (or (car loc2) "section"))
     ((= p3 pmax)
      ;; A special.  Default context right there.
      (setq reftex-default-context-position p3)
      (setq loc3 (car loc3))
      (cond ((null loc3) "section")
            ((symbolp loc3) (symbol-name loc3))
            ((stringp loc3) loc3)
            (t "section")))
     (t ;; This should not happen, I think?
      "section"))))