all messages for Emacs-related lists mirrored at yhetil.org
 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

* Re: Replace org link with footnote
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Max Nikulin @ 2023-11-11  3:54 UTC (permalink / raw)
  To: emacs-orgmode

On 11/11/2023 03:23, Matt wrote:
> Here's a quick hack to replace an Org link with a footnote.
[...]
>    (if (org-in-regexp org-link-bracket-re 1)

During the following discussion I thought on 
`org-export-filter-parse-tree-functions' as a means to transform links 
into footnotes for ox-ascii (it is a bit different from current way to 
put link URLs at the end of the current heading. It should be better 
than regexp-based parsing.

Max Nikulin. [RFC][PATCH] Allow to export to ascii custom link types as 
notes. Sat, 21 Oct 2023 00:21:47 +0700.
https://list.orgmode.org/ugucve$12l4$1@ciao.gmane.io




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

* Re: Replace org link with footnote
  2023-11-11  3:54 ` Max Nikulin
@ 2023-11-11  9:21   ` Matt
  0 siblings, 0 replies; 4+ messages in thread
From: Matt @ 2023-11-11  9:21 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode


 ---- On Sat, 11 Nov 2023 04:54:15 +0100  Max Nikulin  wrote --- 

 > https://list.orgmode.org/ugucve$12l4$1@ciao.gmane.io

Thanks for the reference.  It's always good to relate associated information :)


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

* Re: Replace org link with footnote
  2023-11-10 20:23 Replace org link with footnote Matt
  2023-11-11  3:54 ` Max Nikulin
@ 2023-11-11 10:28 ` Ihor Radchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-11-11 10:28 UTC (permalink / raw)
  To: Matt; +Cc: emacs-orgmode

Matt <matt@excalamus.com> writes:

> ...  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?

I would not mind such a patch.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ 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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.