changeset 104817:90d1a4410a0c

(footnote-prefix): Make it a defcustom. (footnote-mode-map): Move initialization into the declaration. (footnote-minor-mode-map): Define it rather than changing global-map. (footnote-mode): Use define-minor-mode.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 03 Sep 2009 02:21:37 +0000
parents 4129eea9d003
children 7045e9821995
files lisp/ChangeLog lisp/mail/footnote.el
diffstat 2 files changed, 41 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Sep 03 00:36:11 2009 +0000
+++ b/lisp/ChangeLog	Thu Sep 03 02:21:37 2009 +0000
@@ -1,3 +1,11 @@
+2009-09-03  Eduard Wiebe  <usenet@pusto.de>
+	    Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* mail/footnote.el (footnote-prefix): Make it a defcustom.
+	(footnote-mode-map): Move initialization into the declaration.
+	(footnote-minor-mode-map): Define it rather than changing global-map.
+	(footnote-mode): Use define-minor-mode.
+
 2009-09-02  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp.el (tramp-handle-file-attributes-with-ls)
@@ -12,16 +20,14 @@
 	(tramp-method-out-of-band-p): Additional parameter SIZE.
 	(tramp-do-copy-or-rename-file, tramp-handle-file-local-copy)
 	(tramp-handle-write-region): Use it.
-	(tramp-handle-insert-directory): Use "?\ " for compatibility
-	reasons.
+	(tramp-handle-insert-directory): Use "?\ " for compatibility reasons.
 	(tramp-handle-vc-registered): Check, whether the first run did
 	return files to be tested.
 	(tramp-advice-make-auto-save-file-name): Do not call directly
 	`tramp-handle-make-auto-save-file-name', because this would bypass
 	the locking mechanism.
 
-	* net/tramp-compat.el (top): Autoload used functions from
-	tramp.el.
+	* net/tramp-compat.el (top): Autoload used functions from tramp.el.
 	(file-remote-p, process-file, start-file-process, set-file-times)
 	(tramp-compat-file-attributes): Compatibility functions shall not
 	call directly `tramp-handle-*', because this would bypass the
@@ -71,8 +77,7 @@
 	MI command -var-evaluate-expression.
 	(gdb-var-list-children-regexp): Update from regexp-1 in gdb-ui.el
 	and tweak for case of string child.
-	(gdb-var-list-children-handler): Update from handler-1 in
-	gdb-ui.el.
+	(gdb-var-list-children-handler): Update from handler-1 in gdb-ui.el.
 
 2009-09-01  Glenn Morris  <rgm@gnu.org>
 
@@ -187,7 +192,8 @@
 
 	* emacs-lisp/byte-run.el (define-obsolete-face-alias): New macro.
 
-	* apropos.el (apropos-symbols-internal): Handle (obsolete) face aliases.
+	* apropos.el (apropos-symbols-internal):
+	Handle (obsolete) face aliases.
 
 	* faces.el (describe-face): Adjust the output format to be more like
 	describe-variable, and to mention (obsolete) face aliases.
@@ -233,7 +239,7 @@
 	* net/ldap.el (ldap-search-internal): Use with-current-buffer and push.
 
 	* net/imap.el (imap-send-command): Simplify.
-	(imap-wait-for-tag): point-max - buffer-size.
+	(imap-wait-for-tag): point-max -> buffer-size.
 
 	* net/ange-ftp.el (internal-ange-ftp-mode): Use define-derived-mode.
 
--- a/lisp/mail/footnote.el	Thu Sep 03 00:36:11 2009 +0000
+++ b/lisp/mail/footnote.el	Thu Sep 03 02:21:37 2009 +0000
@@ -84,8 +84,14 @@
   :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
 
@@ -143,10 +149,6 @@
 (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]+"
@@ -743,47 +745,32 @@
 	(widen))
       (goto-char (cadr (assq note footnote-pointer-marker-alist))))))
 
-(defvar footnote-mode-map nil
-  "Keymap used for footnote minor mode.")
+(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))
 
-;; 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-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)
+(define-minor-mode footnote-mode
   "Toggle footnote minor mode.
-\\<message-mode-map>
 This minor mode provides footnote support for `message-mode'.  To get
 started, play around with the following keys:
-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")
+\\{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)
@@ -793,9 +780,6 @@
     (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
@@ -808,14 +792,7 @@
 	(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)