[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: Footnotes and org-export, revisited
From: |
Paul R |
Subject: |
[Orgmode] Re: Footnotes and org-export, revisited |
Date: |
Wed, 17 Dec 2008 17:32:29 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
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
- [Orgmode] Footnotes and org-export, revisited, Scot Becker, 2008/12/17
- [Orgmode] Re: Footnotes and org-export, revisited, Paul R, 2008/12/17
- Re: [Orgmode] Footnotes and org-export, revisited, Carsten Dominik, 2008/12/17
- [Orgmode] Re: Footnotes and org-export, revisited, Paul R, 2008/12/17
- [Orgmode] Re: Footnotes and org-export, revisited, Carsten Dominik, 2008/12/17
- [Orgmode] Re: Footnotes and org-export, revisited,
Paul R <=
- [Orgmode] Re: Footnotes and org-export, revisited, Carsten Dominik, 2008/12/17
- [Orgmode] Re: Footnotes and org-export, revisited, Paul R, 2008/12/17
- [Orgmode] Re: Footnotes and org-export, revisited, Scot Becker, 2008/12/17
- Re: [Orgmode] Re: Footnotes and org-export, revisited, Matthew Lundin, 2008/12/17
- Re: [Orgmode] Re: Footnotes and org-export, revisited, Scot Becker, 2008/12/17
- [Orgmode] Re: Footnotes and org-export, revisited, Sivaram Neelakantan, 2008/12/17
- Re: [Orgmode] Re: Footnotes and org-export, revisited, Carsten Dominik, 2008/12/18
- [Orgmode] Re: Footnotes and org-export, revisited, Sivaram Neelakantan, 2008/12/18
- Re: [Orgmode] Re: Footnotes and org-export, revisited, Peter Frings, 2008/12/18
- Re: [Orgmode] Re: Footnotes and org-export, revisited, Peter Frings, 2008/12/18