emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt <matt@excalamus.com>
To: "emacs-orgmode" <emacs-orgmode@gnu.org>
Subject: Replace org link with footnote
Date: Fri, 10 Nov 2023 21:23:06 +0100	[thread overview]
Message-ID: <18bbae70fce.bef9a7e11496525.6297275205814890900@excalamus.com> (raw)
In-Reply-To: 

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	other threads:[~2023-11-10 20:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10 20:23 Matt [this message]
2023-11-11  3:54 ` Replace org link with footnote Max Nikulin
2023-11-11  9:21   ` Matt
2023-11-11 10:28 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18bbae70fce.bef9a7e11496525.6297275205814890900@excalamus.com \
    --to=matt@excalamus.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).