-;;; 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 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000-2011 Free Software Foundation, Inc.
;; Author: Steven L Baur <steve@xemacs.org>
;; Keywords: mail, news
:type 'integer
:group 'footnote)
-(defvar footnote-prefix [(control ?c) ?!]
- "*When not using `message-mode', the prefix to bind in `mode-specific-map'")
+(defcustom footnote-prefix [(control ?c) ?!]
+ "Prefix key to use for Footnote command in Footnote minor mode.
+The value of this variable is checked as part of loading Footnote mode.
+After that, changing the prefix key requires manipulating keymaps."
+ ;; FIXME: the type should be a key-sequence, but it seems Custom
+ ;; doesn't support that yet.
+ ;; :type 'string
+ )
;;; Interface variables that probably shouldn't be changed
(defvar footnote-mouse-highlight 'highlight
"Text property name to enable mouse over highlight.")
-(defvar footnote-mode nil
- "Variable indicating whether footnote minor mode is active.")
-(make-variable-buffer-local 'footnote-mode)
-
;;; Default styles
;;; NUMERIC
(defconst footnote-numeric-regexp "[0-9]+"
;; Latin-1
-(defconst footnote-latin-string "¹²³ºª§¶"
+(defconst footnote-latin-string "¹²³ºª§¶"
"String of Latin-1 footnoting characters.")
;; Note not [...]+, because this style cycles.
(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)
(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.
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'."
;;; 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)
(Footnote-narrow-to-footnotes)
(and (>= old-point (point-min))
(<= old-point (point-max))))))
- (>= (point) (cdar footnote-text-marker-alist)))
+ footnote-text-marker-alist
+ (>= (point) (cdar footnote-text-marker-alist)))
(let ((i 1)
alist-txt rc)
(while (and (setq alist-txt (nth i footnote-text-marker-alist))
(widen))
(goto-char (cadr (assq note footnote-pointer-marker-alist))))))
-(defvar footnote-mode-map nil
- "Keymap used for footnote minor mode.")
-
-;; Set up our keys
-(unless footnote-mode-map
- (setq footnote-mode-map (make-sparse-keymap))
- (define-key footnote-mode-map "a" 'Footnote-add-footnote)
- (define-key footnote-mode-map "b" 'Footnote-back-to-message)
- (define-key footnote-mode-map "c" 'Footnote-cycle-style)
- (define-key footnote-mode-map "d" 'Footnote-delete-footnote)
- (define-key footnote-mode-map "g" 'Footnote-goto-footnote)
- (define-key footnote-mode-map "r" 'Footnote-renumber-footnotes)
- (define-key footnote-mode-map "s" 'Footnote-set-style))
-
-(defvar footnote-minor-mode-map nil
+(defvar footnote-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "a" 'Footnote-add-footnote)
+ (define-key map "b" 'Footnote-back-to-message)
+ (define-key map "c" 'Footnote-cycle-style)
+ (define-key map "d" 'Footnote-delete-footnote)
+ (define-key map "g" 'Footnote-goto-footnote)
+ (define-key map "r" 'Footnote-renumber-footnotes)
+ (define-key map "s" 'Footnote-set-style)
+ map))
+
+(defvar footnote-minor-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map footnote-prefix footnote-mode-map)
+ map)
"Keymap used for binding footnote minor mode.")
-(unless footnote-minor-mode-map
- (define-key global-map footnote-prefix footnote-mode-map))
-
;;;###autoload
-(defun footnote-mode (&optional arg)
- "Toggle footnote minor mode.
-\\<message-mode-map>
-key binding
---- -------
-
-\\[Footnote-add-footnote] Footnote-add-footnote
-\\[Footnote-back-to-message] Footnote-back-to-message
-\\[Footnote-delete-footnote] Footnote-delete-footnote
-\\[Footnote-goto-footnote] Footnote-goto-footnote
-\\[Footnote-renumber-footnotes] Footnote-renumber-footnotes
-\\[Footnote-cycle-style] Footnote-cycle-style
-\\[Footnote-set-style] Footnote-set-style
-"
- (interactive "*P")
+(define-minor-mode footnote-mode
+ "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
;; (filladapt-mode t)
- (setq footnote-mode
- (if (null arg) (not footnote-mode)
- (> (prefix-numeric-value arg) 0)))
(when footnote-mode
;; (Footnote-setup-keybindings)
(make-local-variable 'footnote-style)
(make-local-variable 'footnote-section-tag-regexp)
(make-local-variable 'footnote-start-tag)
(make-local-variable 'footnote-end-tag)
- (if (fboundp 'force-mode-line-update)
- (force-mode-line-update)
- (set-buffer-modified-p (buffer-modified-p)))
(when (boundp 'filladapt-token-table)
;; add tokens to filladapt to match footnotes
(unless (assoc bullet-regexp filladapt-token-table)
(setq filladapt-token-table
(append filladapt-token-table
- (list (list bullet-regexp 'bullet)))))))
-
- (run-hooks 'footnote-mode-hook)))
-
-(unless (assq 'footnote-mode minor-mode-alist)
- (setq minor-mode-alist
- (cons '(footnote-mode footnote-mode-line-string)
- minor-mode-alist)))
+ (list (list bullet-regexp 'bullet)))))))))
(provide 'footnote)
-;; arch-tag: 9bcfb6d7-2161-4caf-8793-700f62400398
;;; footnote.el ends here