From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Footnotes and org-export, revisited Date: Wed, 17 Dec 2008 17:58:58 +0100 Message-ID: <0BC7783A-E7E3-4DD3-98E4-746A9C1EDFB0@uva.nl> References: <5171E67B-8472-409A-A0EE-7EA25D18D58B@uva.nl> <873agmyg4y.fsf@gmail.com> <8244A00C-E3DC-4756-92B2-ABDA5BBB117F@uva.nl> <87r646wyn6.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LCzjm-0002Xb-OB for emacs-orgmode@gnu.org; Wed, 17 Dec 2008 11:59:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LCzjl-0002XJ-Bd for emacs-orgmode@gnu.org; Wed, 17 Dec 2008 11:59:05 -0500 Received: from [199.232.76.173] (port=48244 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCzjl-0002XG-32 for emacs-orgmode@gnu.org; Wed, 17 Dec 2008 11:59:05 -0500 Received: from mail-ew0-f13.google.com ([209.85.219.13]:48602) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LCzjk-0003vY-E2 for emacs-orgmode@gnu.org; Wed, 17 Dec 2008 11:59:04 -0500 Received: by ewy6 with SMTP id 6so4572590ewy.18 for ; Wed, 17 Dec 2008 08:59:02 -0800 (PST) In-Reply-To: <87r646wyn6.fsf@gmail.com> 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: Paul R Cc: emacs-orgmode@gnu.org Hi Paul, thanks for this latest version! No need for you to change anything right now, let me first play with it and seen what else I might think off. I really like your idea to use [fn:label] and [fn::Full footnote text], nice syntactic sugar. - Carsten On Dec 17, 2008, at 5:32 PM, Paul R wrote: > 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