mail[Muse-el-discuss] Footnote Patch, (was Footnote-mode limitation )

Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]



Posted by paul r on November 21, 2007 - 00:18:
2007/11/15, paul r <>:
2007/11/15, paul r <>:
2007/11/15, Suno Ano <itsmethemax@xxxxxx>:
 pr> As footnote-mode is really usefull with muse, it would be nice if
 pr> it worked out of the box.

I am second to that.

 pr> So if anyone can make sure footnote-init code is integrated
 pr> upstream, or find another solution for muse, it would help a lot.

As already pointed out, footnote.el is part of GNU Emacs so could anyone
with CVS access (Michael?) put the improved footnote+.el upstream?

actually, that is true that footnote.el is part of emacs. More
precisely, is it part of the mail part of emacs. It has been primarily
written for people writing emails, so that there is no need to load
existing footnote as an email is generaly to be sent at the end of the
editing session.

Concerning the patch, for some magic reason I did not find yet, it
works on some files but not on some others, and the behaviour depends
on the file. If they are other people wanting to track down this bug,
it would be very welcome and we could end up with a nice, reliable
improved footnote.el.

I was wondering ... We are trying to keep consistent footnotes
ordering because with Muse there is an absolute need for such
ordering. Instead of relying on external tool like footnote-mode,
would it be hard to link footnote reference and definition with a
keyword (instead of ordered numbers), as it is done with
references[fn:reference_def] ? Then if I want to make a
footnote[fn:footnote_def] in the middle of my text, I can do so and at
the end write my footnote content. Please note that the order of
references is not the same as the order of definitions. What do you
think about that ?

[fn:footnote_def]  a footnote is a little note at the bottom of a page

[fn:reference_def] a reference is a ...

here is a bit of code I just wrote that helps a lot with footnotes.
Here is how to get it to work :
-- a footnote reference is defined as[fn:key], where fn: is mandatory
and key is up to you
 - it must stick to the preceding word
 - it must begin with fn: (could easily be customizable)
-- a footnote definition must occur after the reference, ie must be
later in the file.
 - it must start the line with the reference key followed by a space
and the definition
 - they can be multiline
 - a blanck line must follow definition

what it provides now :
 - no more unflexible numbering, you can insert as many footnotes as
you like without renumbering them all
 - no more problem with footnote-mode unable to parse file
 - no mandatory order for definition, they can be in any order
provided each of them follow reference
 - definition are close to references, making source reading easier
(no need to scroll)

Exemple of Muse file :
I like apples[fn:apples] very much because they taste good[fn:taste]
and look good.

[fn:taste] taste is a matter of taste ...

[fn:apples] apple is a fruit

When Newton[fn:newton]  saw an apple fall, he found
In that slight startle from his contemplation —
'Tis said (for I'll not answer above ground
For any sage's creed or calculation) —

[fn:newton] physicist
(Notice that the first 2 definitions are unordered, that does not
matter, as reference order will be observed.)

The given code will rewrite the buffer so that is looks like an
ordinary muse buffer with ordered and numbered footnotes, so that
everything existing in Muse do deal with footnote keeps working. As I
did not find a suitable general hook for all style, I use the code in
a function triggered by :before parameter of the publish style, which
has a perfect behaviour as it will only reformat a temporary copy of
the muse source, before publication, therefore will work as expected
without altering muse buffer. If you want to visualy see what happens,
you can test it in a Muse buffer formated as above, and by typing
(muse-build-list-of-footnotes) then hit C-x C-e.
I hope at least the idea will find its way in muse source code as it
provide flexible and pleasant footnote handling. Of course, this short
code is GPL, and could easily be improved.

Here is the function :
(defun muse-build-list-of-footnotes ()
  (let ((ref "")(def "")(count 0)(deb 0)(def-deb 0)(def-fin 0)(liste
'())(found nil))
      (goto-char (point-min))
      (while (re-search-forward "\\(\\w\\)\\[\\(fn:\\w+\\)\\]" nil t)
        (setq found t)
        (incf count)
        (setq ref (match-string 2))
        (replace-match (concat "\\1[" (number-to-string count) "]"))
          (re-search-forward (concat "^\\[" ref "\\]"))
          (setq deb (match-beginning 0))
          (setq def-deb (match-end 0))
          (if (re-search-forward "\n\n" nil t)
              (setq def-fin (match-beginning 0))
            (setq def-fin (point-max)))
          (push (buffer-substring def-deb def-fin) liste)
          (delete-region deb (min (+ def-fin 2) (point-max)))
      (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) "]" elem 
      (if found (insert (concat "\n\nFootnotes:\n" def)) nil)

Related Messages

Powered by MHonArc, Updated Wed Nov 28 18:01:34 2007