From: Paul R <paul.r.ml@gmail.com>
To: Carsten Dominik <dominik@science.uva.nl>
Cc: emacs-orgmode@gnu.org
Subject: Re: Footnotes and org-export, revisited
Date: Wed, 17 Dec 2008 17:32:29 +0100 [thread overview]
Message-ID: <87r646wyn6.fsf@gmail.com> (raw)
In-Reply-To: <8244A00C-E3DC-4756-92B2-ABDA5BBB117F@uva.nl> (Carsten Dominik's message of "Wed, 17 Dec 2008 17:08:23 +0100")
Hi Carsten
Carsten> Hi Paul, I think we can easily have both, I can do the coding
Carsten> based on your function, this is a small change.
Ok so here is the latest version in my .emacs :
You'll need (eval-when-compile (require 'cl)) because of rx ... When
I wrote this function I wanted to try rx, but if it is annoying I can
rewrite back all the regexp as strings.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq muse-footnote-prefix "fn:")
;; todo : handle footnotes in comments
(defun muse-build-list-of-footnotes ()
(let ((refkey "")(def "")(count 0)(deb 0)(def-deb 0)(def-fin 0)(liste nil)(found nil))
(save-excursion
(goto-char (point-min))
(while (re-search-forward
(rx (minimal-match
(seq
(one-or-more not-newline)
"[" (group (and (eval muse-footnote-prefix)
(one-or-more wordchar)))
"]")))
nil t)
(setq found t)
(incf count)
(setq refkey (match-string 1))
(replace-match (number-to-string count) nil nil nil 1)
(save-excursion
(unless (re-search-forward
(dont-compile
(rx (seq bol
"[" (eval refkey) "]"
(zero-or-more blank)))) nil t)
(setq def (list (concat "Unable to find footnote definition for " refkey)))
(signal 'quit def))
(setq deb (match-beginning 0))
(setq def-deb (match-end 0))
(re-search-forward
(rx (or "\n\n"
(seq "\n[" (eval muse-footnote-prefix))
(seq (zero-or-one "\n") buffer-end))))
(setq def-fin (match-beginning 0))
(push (buffer-substring def-deb def-fin) liste)
(delete-region deb def-fin)
)
)
(goto-char (point-max))
(setq liste (reverse liste))
(setq count 0)
(setq def (dolist (elem liste def)
(incf count)
(setq def (concat def "[" (number-to-string count) "] "
(muse-publish-escape-specials-in-string elem 'document)
"\n\n"))))
(if found (insert (concat "\n\nFootnotes:\n" def)) nil)
)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
--
Paul
next prev parent reply other threads:[~2008-12-17 16:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-17 12:52 Footnotes and org-export, revisited Scot Becker
2008-12-17 13:28 ` Paul R
2008-12-17 13:31 ` Carsten Dominik
2008-12-17 15:29 ` Paul R
2008-12-17 15:59 ` Scot Becker
2008-12-17 20:54 ` Matthew Lundin
2008-12-17 22:23 ` Scot Becker
2008-12-17 16:08 ` Carsten Dominik
2008-12-17 16:32 ` Paul R [this message]
2008-12-17 16:58 ` Carsten Dominik
2008-12-17 17:25 ` Paul R
2008-12-17 17:18 ` Sivaram Neelakantan
2008-12-18 8:08 ` Carsten Dominik
2008-12-18 17:13 ` Sivaram Neelakantan
2008-12-18 10:34 ` Peter Frings
2008-12-18 10:55 ` Peter Frings
2008-12-17 14:04 ` Jörg Hagmann
2009-01-01 9:07 ` Carsten Dominik
2009-01-01 16:48 ` Matthew Lundin
2009-01-01 17:10 ` Carsten Dominik
2009-01-02 15:10 ` Matthew Lundin
2009-01-03 8:17 ` Carsten Dominik
2009-01-03 22:53 ` Matthew Lundin
2009-01-04 7:39 ` Carsten Dominik
2009-01-12 11:29 ` Scot Becker
2009-01-12 14:21 ` Paul R
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=87r646wyn6.fsf@gmail.com \
--to=paul.r.ml@gmail.com \
--cc=dominik@science.uva.nl \
--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).