Function: org-footnote-renumber-fn:N
org-footnote-renumber-fn:N is an interactive and byte-compiled
function defined in org-footnote.el.gz.
Signature
(org-footnote-renumber-fn:N)
Documentation
Order numbered footnotes into a sequence in the document.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-footnote.el.gz
;;;; Sorting, Renumbering, Normalizing
(defun org-footnote-renumber-fn:N ()
"Order numbered footnotes into a sequence in the document."
(interactive)
(let* ((c 0)
(references (cl-remove-if-not
(lambda (r) (string-match-p "\\`[0-9]+\\'" (car r)))
(org-footnote--collect-references)))
(alist (mapcar (lambda (l) (cons l (number-to-string (cl-incf c))))
(delete-dups (mapcar #'car references)))))
(org-with-wide-buffer
;; Re-number references.
(dolist (ref references)
(goto-char (nth 1 ref))
(org-footnote--set-label (cdr (assoc (nth 0 ref) alist))))
;; Re-number definitions.
(goto-char (point-min))
(while (re-search-forward "^\\[fn:\\([0-9]+\\)\\]" nil t)
(replace-match (or (cdr (assoc (match-string 1) alist))
;; Un-referenced definitions get higher
;; numbers.
(number-to-string (cl-incf c)))
nil nil nil 1)))))