emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: Footnotes and org-export, revisited


From: Carsten Dominik
Subject: [Orgmode] Re: Footnotes and org-export, revisited
Date: Wed, 17 Dec 2008 17:58:58 +0100

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]