Function: reftex-uniquify-label

reftex-uniquify-label is a byte-compiled function defined in reftex-ref.el.gz.

Signature

(reftex-uniquify-label LABEL &optional FORCE SEPARATOR)

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-ref.el.gz
(defun reftex-uniquify-label (label &optional force separator)
  ;; Make label unique by appending a number.
  ;; Optional FORCE means, force appending a number, even if label is unique.
  ;; Optional SEPARATOR is a string to stick between label and number.

  ;; Ensure access to scanning info
  (reftex-access-scan-info)

  (cond
   ((and (not force)
         (not (assoc label (symbol-value reftex-docstruct-symbol))))
    label)
   (t
    (let* ((label-numbers (assq 'label-numbers
                                (symbol-value reftex-docstruct-symbol)))
           (label-numbers-alist (cdr label-numbers))
           (cell (or (assoc label label-numbers-alist)
                     (car (setcdr label-numbers
                                  (cons (cons label 0)
                                        label-numbers-alist)))))
           (num (1+ (cdr cell)))
           (sep (or separator "")))
      (while (assoc (concat label sep (int-to-string num))
                    (symbol-value reftex-docstruct-symbol))
        (cl-incf num))
      (setcdr cell num)
      (concat label sep (int-to-string num))))))