]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/footnote.el
Fix previous change:
[gnu-emacs] / lisp / mail / footnote.el
index 7576269c9f508851882138f6982215f1bf97cc08..b4e8d20c4ef7d2a6abf10fee054faad634abe868 100644 (file)
@@ -1,6 +1,6 @@
-;;; footnote.el --- Footnote support for message mode
+;;; footnote.el --- footnote support for message mode  -*- coding: iso-latin-1;-*-
 
-;; Copyright (C) 1997 by Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000 by Free Software Foundation, Inc.
 
 ;; Author: Steven L Baur <steve@xemacs.org>
 ;; Keywords: mail, news
 ;; Reasonable Undo support.
 ;; more language styles.
 
-;;; Change Log:
-
-;; May-31-1998: In `Footnote-make-hole', `concat' was called with integer
-;;              argument; now use `Footnote-index-to-string' and `format'
-;; Apr-04-1997: Added option to narrow buffer when editing the text of
-;;             a footnote.
-;;             Insertion and renumbering now works.
-;;             Deletion and renumbering now works.
-;;             Footnote styles implemented.
-;; Apr-05-1997: Added dumb version of footnote-set-style.
-;;             Merged minor corrections from Hrvoje Niksic, Sudish Joseph,
-;;             and David Moore.
-;;             Remove absolute dependency on message-mode.
-;;             Replicate letters when footnote numbers hit the end of
-;;             the alphabet.
-;; Apr-06-1997: Emacs portability patches from Lars Magne Ingebrigtsen.
-;; Apr-18-1997:        Stricter matching of footnote tag.  (Idea from Colin Rafferty)
-;; May-16-1997:        Allow customization of spacing of footnote body tag.  (Idea
-;;             from Samuel Tardieu).
-
 ;;; Code:
 
 (eval-when-compile
@@ -63,6 +43,7 @@
 
 (defgroup footnote nil
   "Support for footnotes in mail and news messages."
+  :version "21.1"
   :group 'message)
 
 (defcustom footnote-mode-line-string " FN"
@@ -91,18 +72,6 @@ If nil, no blank line will be inserted."
   :type 'boolean
   :group 'footnote)
 
-(defcustom footnote-style 'numeric
-  "*Style used for footnoting.
-numeric == 1, 2, 3, ...
-english-lower == a, b, c, ...
-english-upper == A, B, C, ...
-roman-lower == i, ii, iii, iv, v, ...
-roman-upper == I, II, III, IV, V, ...
-Some versions of XEmacs and Emacs/mule may support further styles
-like 'hebrew, 'greek-lower, and 'greek-upper."
-  :type 'symbol
-  :group 'footnote)
-
 (defcustom footnote-use-message-mode t
   "*If non-nil assume Footnoting will be done in message-mode."
   :type 'boolean
@@ -121,15 +90,22 @@ like 'hebrew, 'greek-lower, and 'greek-upper."
 (defconst footnote-section-tag "Footnotes: "
   "*Tag inserted at beginning of footnote section.")
 
-(defconst footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: "
-  "*Regexp which indicates the start of a footnote section.")
+(defcustom footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: "
+  "*Regexp which indicates the start of a footnote section.
+See also `footnote-section-tag'."
+  :type 'regexp
+  :group 'footnote)
 
 ;; The following three should be consumed by footnote styles.
-(defconst footnote-start-tag "["
-  "*String used to denote start of numbered footnote.")
+(defcustom footnote-start-tag "["
+  "*String used to denote start of numbered footnote."
+  :type 'string
+  :group 'footnote)
 
-(defconst footnote-end-tag "]"
-  "*String used to denote end of numbered footnote.")
+(defcustom footnote-end-tag "]"
+  "*String used to denote end of numbered footnote."
+  :type 'string
+  :group 'footnote)
 
 (defvar footnote-signature-separator (if (boundp 'message-signature-separator)
                                         message-signature-separator
@@ -185,7 +161,7 @@ Wrapping around the alphabet implies successive repetitions of letters."
       (setq rc (concat rc chr))
       (setq rep (1- rep)))
     rc))
-  
+
 ;;; ENGLISH LOWER
 (defconst footnote-english-lower "abcdefghijklmnopqrstuvwxyz"
   "Lower case English alphabet.")
@@ -285,19 +261,44 @@ Wrapping around the alphabet implies successive repetitions of letters."
                   (- n (car rom-low-pair))
                   footnote-roman-list)))))))
 
+;; Latin-1
+
+(defconst footnote-latin-regexp "¹²³ºª§¶"
+  "Regexp for Latin-1 footnoting characters.")
+
+(defun Footnote-latin (n)
+  "Latin-1 footnote style.
+Use a range of Latin-1 non-ASCII characters for footnoting."
+  (string (aref footnote-latin-regexp
+               (mod (1- n) (length footnote-latin-regexp)))))
+
 ;;; list of all footnote styles
 (defvar footnote-style-alist
   `((numeric Footnote-numeric ,footnote-numeric-regexp)
     (english-lower Footnote-english-lower ,footnote-english-lower-regexp)
     (english-upper Footnote-english-upper ,footnote-english-upper-regexp)
     (roman-lower Footnote-roman-lower ,footnote-roman-lower-regexp)
-    (roman-upper Footnote-roman-upper ,footnote-roman-upper-regexp))
+    (roman-upper Footnote-roman-upper ,footnote-roman-upper-regexp)
+    (latin Footnote-latin ,footnote-latin-regexp))
   "Styles of footnote tags available.
 By default only boring Arabic numbers, English letters and Roman Numerals
 are available.
 See footnote-han.el, footnote-greek.el and footnote-hebrew.el for more
 exciting styles.")
 
+(defcustom footnote-style 'numeric
+  "*Style used for footnoting.
+numeric == 1, 2, 3, ...
+english-lower == a, b, c, ...
+english-upper == A, B, C, ...
+roman-lower == i, ii, iii, iv, v, ...
+roman-upper == I, II, III, IV, V, ...
+latin == ¹ ² ³ º ª § ¶
+See also variables `footnote-start-tag' and `footnote-end-tag'."
+  :type (cons 'choice (mapcar (lambda (x) (list 'const (car x)))
+                             footnote-style-alist))
+  :group 'footnote)
+
 ;;; Style utilities & functions
 (defun Footnote-style-p (style)
   "Return non-nil if style is a valid style known to footnote-mode."
@@ -481,7 +482,7 @@ styles."
   (Footnote-goto-char-point-max)
   (if (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)
       (save-restriction
-       (when footnote-narrow-to-footnotes-when-editing 
+       (when footnote-narrow-to-footnotes-when-editing
          (Footnote-narrow-to-footnotes))
        (Footnote-goto-footnote (1- arg)) ; evil, FIXME (less evil now)
        ;; (message "Inserting footnote %d" arg)
@@ -512,7 +513,7 @@ styles."
 
 (defun Footnote-text-under-cursor ()
   "Return the number of footnote if in footnote text.
-Nil is returned if the cursor is not positioned over the text of
+Return nil if the cursor is not positioned over the text of
 a footnote."
   (when (and (let ((old-point (point)))
               (save-excursion
@@ -535,7 +536,7 @@ a footnote."
 
 (defun Footnote-under-cursor ()
   "Return the number of the footnote underneath the cursor.
-Nil is returned if the cursor is not over a footnote."
+Return nil if the cursor is not over a footnote."
   (or (get-text-property (point) 'footnote-number)
       (Footnote-text-under-cursor)))
 
@@ -553,9 +554,9 @@ Nil is returned if the cursor is not over a footnote."
          (unless rc
            (setq rc (car alist-ptr)))
          (save-excursion
-           (message "Renumbering from %s to %s" 
+           (message "Renumbering from %s to %s"
                     (Footnote-index-to-string (car alist-ptr))
-                    (Footnote-index-to-string 
+                    (Footnote-index-to-string
                      (1+ (car alist-ptr))))
            (Footnote-renumber (car alist-ptr)
                               (1+ (car alist-ptr))
@@ -664,12 +665,12 @@ specified, jump to the text of that footnote."
        (setq footnote (assq arg footnote-text-marker-alist))))
     (if footnote
        (goto-char (cdr footnote))
-      (if (= arg 0)
+      (if (eq arg 0)
          (progn
            (goto-char (point-max))
            (re-search-backward (concat "^" footnote-section-tag-regexp))
            (forward-line 1))
-       (error "I don't see a footnote here.")))))
+       (error "I don't see a footnote here")))))
 
 (defun Footnote-back-to-message (&optional arg)
   "Move cursor back to footnote referent.