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