Here's a quick hack to replace an Org link with a footnote.  Maybe a fun first 
commit for someone would be to update `org-footnote-new` to accept optional 
LABEL and DEFINITION arguments that allow a footnote to be created 
programmatically?

(defun my-replace-link-with-footnote ()
  "Replace an org link with a footnote.

Place the link target in the footnote and the description in the
location of the original Org link."
  (interactive)
  (if (org-in-regexp org-link-bracket-re 1)
      (save-excursion
        (let ((remove (list (match-beginning 0) (match-end 0)))
              (link (org-match-string-no-properties 1))
              (description  ; link is description
               (if (match-end 2)
                   (org-match-string-no-properties 2)
                 (org-match-string-no-properties 1))))
          (apply 'delete-region remove)
          ;; replaces link with footnote and jumps to footnote
          (call-interactively 'org-footnote-new nil)
          (insert " " link)
          (beginning-of-line)
          ;; follow link back to original point
          (org-open-at-point)
          (insert description)))))


Reply via email to