emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Replace org link with footnote
@ 2023-11-10 20:23 Matt
  2023-11-11  3:54 ` Max Nikulin
  2023-11-11 10:28 ` Ihor Radchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Matt @ 2023-11-10 20:23 UTC (permalink / raw)
  To: emacs-orgmode

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)))))



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-11 10:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-10 20:23 Replace org link with footnote Matt
2023-11-11  3:54 ` Max Nikulin
2023-11-11  9:21   ` Matt
2023-11-11 10:28 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).