From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul R Subject: Re: Footnotes and org-export, revisited Date: Wed, 17 Dec 2008 17:32:29 +0100 Message-ID: <87r646wyn6.fsf@gmail.com> References: <5171E67B-8472-409A-A0EE-7EA25D18D58B@uva.nl> <873agmyg4y.fsf@gmail.com> <8244A00C-E3DC-4756-92B2-ABDA5BBB117F@uva.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LCzKD-0005Ny-94 for emacs-orgmode@gnu.org; Wed, 17 Dec 2008 11:32:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LCzKB-0005NK-DU for emacs-orgmode@gnu.org; Wed, 17 Dec 2008 11:32:40 -0500 Received: from [199.232.76.173] (port=36929 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCzKB-0005N7-3O for emacs-orgmode@gnu.org; Wed, 17 Dec 2008 11:32:39 -0500 Received: from mail-ew0-f13.google.com ([209.85.219.13]:44010) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LCzKA-0003Q4-JO for emacs-orgmode@gnu.org; Wed, 17 Dec 2008 11:32:38 -0500 Received: by ewy6 with SMTP id 6so4555531ewy.18 for ; Wed, 17 Dec 2008 08:32:37 -0800 (PST) In-Reply-To: <8244A00C-E3DC-4756-92B2-ABDA5BBB117F@uva.nl> (Carsten Dominik's message of "Wed, 17 Dec 2008 17:08:23 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: emacs-orgmode@gnu.org 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