emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Replace org link with footnote


From: Matt
Subject: Replace org link with footnote
Date: Fri, 10 Nov 2023 21:23:06 +0100
User-agent: Zoho Mail

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

[Prev in Thread] Current Thread [Next in Thread]