Function: org-export-new-reference

org-export-new-reference is a byte-compiled function defined in ox.el.gz.

Signature

(org-export-new-reference REFERENCES)

Documentation

Return a unique reference, among REFERENCES.

REFERENCES is an alist whose values are in-use references, as numbers. Returns a number, which is the internal representation of a reference. See also org-export-format-reference.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
;;;; For References
;;
;; `org-export-get-reference' associate a unique reference for any
;; object or element.  It uses `org-export-new-reference' and
;; `org-export-format-reference' to, respectively, generate new
;; internal references and turn them into a string suitable for
;; output.
;;
;; `org-export-get-ordinal' associates a sequence number to any object
;; or element.

(defun org-export-new-reference (references)
  "Return a unique reference, among REFERENCES.
REFERENCES is an alist whose values are in-use references, as
numbers.  Returns a number, which is the internal representation
of a reference.  See also `org-export-format-reference'."
  ;; Generate random 7 digits hexadecimal numbers.  Collisions
  ;; increase exponentially with the numbers of references.  However,
  ;; the odds for encountering at least one collision with 1000 active
  ;; references in the same document are roughly 0.2%, so this
  ;; shouldn't be the bottleneck.
  (let ((new (random #x10000000)))
    (while (rassq new references) (setq new (random #x10000000)))
    new))