]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/footnote.el
Merge from emacs-24
[gnu-emacs] / lisp / mail / footnote.el
index f6bf1127f5a124a12ec7b9b60456bfe996727a60..e342e0ae97790165778e2022f2c7f52449548d6f 100644 (file)
@@ -1,7 +1,6 @@
-;;; footnote.el --- footnote support for message mode  -*- coding: iso-latin-1;-*-
+;;; footnote.el --- footnote support for message mode  -*- coding: utf-8;-*-
 
-;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000-2012 Free Software Foundation, Inc.
 
 ;; Author: Steven L Baur <steve@xemacs.org>
 ;; Keywords: mail, news
@@ -36,9 +35,8 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl)
-  (defvar filladapt-token-table))
+(eval-when-compile (require 'cl-lib))
+(defvar filladapt-token-table)
 
 (defgroup footnote nil
   "Support for footnotes in mail and news messages."
@@ -127,10 +125,12 @@ has no effect on buffers already displaying footnotes."
   :type 'string
   :group 'footnote)
 
-(defvar footnote-signature-separator (if (boundp 'message-signature-separator)
-                                        message-signature-separator
-                                      "^-- $")
-  "*String used to recognize .signatures.")
+(defcustom footnote-signature-separator (if (boundp 'message-signature-separator)
+                                           message-signature-separator
+                                         "^-- $")
+  "Regexp used by Footnote mode to recognize signatures."
+  :type 'regexp
+  :group 'footnote)
 
 ;;; Private variables
 
@@ -279,7 +279,7 @@ Wrapping around the alphabet implies successive repetitions of letters."
 
 ;; Latin-1
 
-(defconst footnote-latin-string "¹²³ºª§¶"
+(defconst footnote-latin-string "¹²³ºª§¶"
   "String of Latin-1 footnoting characters.")
 
 ;; Note not [...]+, because this style cycles.
@@ -292,6 +292,25 @@ Use a range of Latin-1 non-ASCII characters for footnoting."
   (string (aref footnote-latin-string
                (mod (1- n) (length footnote-latin-string)))))
 
+;; Unicode
+
+(defconst footnote-unicode-string "⁰¹²³⁴⁵⁶⁷⁸⁹"
+  "String of Unicode footnoting characters.")
+
+(defconst footnote-unicode-regexp (concat "[" footnote-unicode-string "]+")
+  "Regexp for Unicode footnoting characters.")
+
+(defun Footnote-unicode (n)
+  "Unicode footnote style.
+Use Unicode characters for footnoting."
+  (let (modulus result done)
+    (while (not done)
+      (setq modulus (mod n 10)
+            n (truncate n 10))
+      (and (zerop n) (setq done t))
+      (push (aref footnote-unicode-string modulus) result))
+    (apply #'string result)))
+
 ;;; list of all footnote styles
 (defvar footnote-style-alist
   `((numeric Footnote-numeric ,footnote-numeric-regexp)
@@ -299,7 +318,8 @@ Use a range of Latin-1 non-ASCII characters for footnoting."
     (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)
-    (latin Footnote-latin ,footnote-latin-regexp))
+    (latin Footnote-latin ,footnote-latin-regexp)
+    (unicode Footnote-unicode ,footnote-unicode-regexp))
   "Styles of footnote tags available.
 By default only boring Arabic numbers, English letters and Roman Numerals
 are available.
@@ -313,9 +333,13 @@ 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 == ¹ ² ³ º ª § ¶
+latin == ¹ ² ³ º ª § ¶
+unicode == ¹, ², ³, ...
 See also variables `footnote-start-tag' and `footnote-end-tag'.
 
+Note: some characters in the unicode style may not show up
+properly if the default font does not contain those characters.
+
 Customizing this variable has no effect on buffers already
 displaying footnotes.  To change the style of footnotes in such a
 buffer use the command `Footnote-set-style'."
@@ -325,7 +349,7 @@ buffer use the command `Footnote-set-style'."
 
 ;;; Style utilities & functions
 (defun Footnote-style-p (style)
-  "Return non-nil if style is a valid style known to footnote-mode."
+  "Return non-nil if style is a valid style known to `footnote-mode'."
   (assq style footnote-style-alist))
 
 (defun Footnote-index-to-string (index)
@@ -619,12 +643,12 @@ If the variable `footnote-narrow-to-footnotes-when-editing' is set,
 the buffer is narrowed to the footnote body.  The restriction is removed
 by using `Footnote-back-to-message'."
   (interactive "*P")
-  (let (num)
-    (if footnote-text-marker-alist
-       (if (< (point) (cadar (last footnote-pointer-marker-alist)))
-           (setq num (Footnote-make-hole))
-         (setq num (1+ (caar (last footnote-text-marker-alist)))))
-      (setq num 1))
+  (let ((num
+         (if footnote-text-marker-alist
+             (if (< (point) (cl-cadar (last footnote-pointer-marker-alist)))
+                 (Footnote-make-hole)
+               (1+ (caar (last footnote-text-marker-alist))))
+           1)))
     (message "Adding footnote %d" num)
     (Footnote-insert-footnote num)
     (insert-before-markers (make-string footnote-body-tag-spacing ? ))
@@ -765,9 +789,14 @@ being set it is automatically widened."
 
 ;;;###autoload
 (define-minor-mode footnote-mode
-  "Toggle footnote minor mode.
-This minor mode provides footnote support for `message-mode'.  To get
-started, play around with the following keys:
+  "Toggle Footnote mode.
+With a prefix argument ARG, enable Footnote mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil.
+
+Footnode mode is a buffer-local minor mode.  If enabled, it
+provides footnote support for `message-mode'.  To get started,
+play around with the following keys:
 \\{footnote-minor-mode-map}"
   :lighter    footnote-mode-line-string
   :keymap     footnote-minor-mode-map