Function: org-footnote-new
org-footnote-new is an interactive and byte-compiled function defined
in org-footnote.el.gz.
Signature
(org-footnote-new)
Documentation
Insert a new footnote.
This command prompts for a label. If this is a label referencing an existing label, only insert the label. If the footnote label is empty or new, let the user edit the definition of the footnote.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-footnote.el.gz
;;;; Adding, Deleting Footnotes
(defun org-footnote-new ()
"Insert a new footnote.
This command prompts for a label. If this is a label referencing an
existing label, only insert the label. If the footnote label is empty
or new, let the user edit the definition of the footnote."
(interactive)
(unless (org-footnote--allow-reference-p)
(user-error "Cannot insert a footnote here"))
(let* ((all (org-footnote-all-labels))
(label
(unless (eq org-footnote-auto-label 'anonymous)
(if (eq org-footnote-auto-label 'random)
(format "%x" (abs (random)))
(org-footnote-normalize-label
(let ((propose (org-footnote-unique-label all)))
(if (eq org-footnote-auto-label t) propose
(completing-read
"Label (leave empty for anonymous): "
(mapcar #'list all) nil nil
(and (eq org-footnote-auto-label 'confirm) propose)))))))))
(cond ((not label)
(insert "[fn::]")
(backward-char 1))
((member label all)
(insert "[fn:" label "]")
(message "New reference to existing note"))
(org-footnote-define-inline
(insert "[fn:" label ":]")
(backward-char 1)
(org-footnote-auto-adjust-maybe))
(t
(insert "[fn:" label "]")
(let ((p (org-footnote-create-definition label)))
;; `org-footnote-goto-definition' needs to be called
;; after `org-footnote-auto-adjust-maybe'. Otherwise
;; both label and location of the definition are lost.
;; On the contrary, it needs to be called before
;; `org-edit-footnote-reference' so that the remote
;; editing buffer can display the correct label.
(if (ignore-errors (org-footnote-goto-definition label p))
(org-footnote-auto-adjust-maybe)
;; Definition was created outside current scope: edit
;; it remotely.
(org-footnote-auto-adjust-maybe)
(org-edit-footnote-reference)))))))