changeset 108215:8264830363ca

Use define-minor-mode in Gnus where applicable. * mml.el (mml-mode): Use define-minor-mode. * gnus-undo.el (gnus-undo-mode-map): Initialize in declaration. (gnus-undo-mode): Use define-minor-mode. * gnus-sum.el (gnus-dead-summary-mode-map): Initialize in declaration. (gnus-dead-summary-mode): Use define-minor-mode. * gnus-salt.el (gnus-pick-mode-map, gnus-binary-mode-map): Initialize in declaration. (gnus-pick-mode, gnus-binary-mode): Use define-minor-mode. * gnus-ml.el (gnus-mailing-list-mode-map): Initialize in declaration. (gnus-mailing-list-mode): Use define-minor-mode. * gnus-draft.el (gnus-draft-mode-map): Initialize in declaration. (gnus-draft-mode): Use define-minor-mode. * gnus-dired.el (gnus-dired-mode-map): Initialize in declaration. (gnus-dired-mode): Use define-minor-mode.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 02 May 2010 20:41:45 -0400
parents 000b400531eb
children 2fb32340c261
files lisp/gnus/ChangeLog lisp/gnus/gnus-dired.el lisp/gnus/gnus-draft.el lisp/gnus/gnus-ml.el lisp/gnus/gnus-salt.el lisp/gnus/gnus-start.el lisp/gnus/gnus-sum.el lisp/gnus/gnus-topic.el lisp/gnus/gnus-undo.el lisp/gnus/mml.el
diffstat 10 files changed, 152 insertions(+), 196 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gnus/ChangeLog	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/ChangeLog	Sun May 02 20:41:45 2010 -0400
@@ -1,3 +1,21 @@
+2010-05-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Use define-minor-mode in Gnus where applicable.
+	* mml.el (mml-mode): Use define-minor-mode.
+	* gnus-undo.el (gnus-undo-mode-map): Initialize in declaration.
+	(gnus-undo-mode): Use define-minor-mode.
+	* gnus-sum.el (gnus-dead-summary-mode-map): Initialize in declaration.
+	(gnus-dead-summary-mode): Use define-minor-mode.
+	* gnus-salt.el (gnus-pick-mode-map, gnus-binary-mode-map):
+	Initialize in declaration.
+	(gnus-pick-mode, gnus-binary-mode): Use define-minor-mode.
+	* gnus-ml.el (gnus-mailing-list-mode-map): Initialize in declaration.
+	(gnus-mailing-list-mode): Use define-minor-mode.
+	* gnus-draft.el (gnus-draft-mode-map): Initialize in declaration.
+	(gnus-draft-mode): Use define-minor-mode.
+	* gnus-dired.el (gnus-dired-mode-map): Initialize in declaration.
+	(gnus-dired-mode): Use define-minor-mode.
+
 2010-04-27  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-util.el: Don't load tm and apel XEmacs packages when compiling.
--- a/lisp/gnus/gnus-dired.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/gnus-dired.el	Sun May 02 20:41:45 2010 -0400
@@ -55,17 +55,12 @@
 (autoload 'message-buffers "message")
 (autoload 'gnus-print-buffer "gnus-sum")
 
-(defvar gnus-dired-mode nil
-  "Minor mode for intersections of MIME mail composition and dired.")
-
-(defvar gnus-dired-mode-map nil)
-
-(unless gnus-dired-mode-map
-  (setq gnus-dired-mode-map (make-sparse-keymap))
-
-  (define-key gnus-dired-mode-map "\C-c\C-m\C-a" 'gnus-dired-attach)
-  (define-key gnus-dired-mode-map "\C-c\C-m\C-l" 'gnus-dired-find-file-mailcap)
-  (define-key gnus-dired-mode-map "\C-c\C-m\C-p" 'gnus-dired-print))
+(defvar gnus-dired-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c\C-m\C-a" 'gnus-dired-attach)
+    (define-key map "\C-c\C-m\C-l" 'gnus-dired-find-file-mailcap)
+    (define-key map "\C-c\C-m\C-p" 'gnus-dired-print)
+    map))
 
 ;; FIXME: Make it customizable, change the default to `mail-user-agent' when
 ;; this file is renamed (e.g. to `dired-mime.el').
@@ -89,19 +84,13 @@
 			       gnus-user-agent)
 		(function :tag "Other")))
 
-(defun gnus-dired-mode (&optional arg)
+(define-minor-mode gnus-dired-mode
   "Minor mode for intersections of gnus and dired.
 
 \\{gnus-dired-mode-map}"
-  (interactive "P")
-  (when (eq major-mode 'dired-mode)
-    (set (make-local-variable 'gnus-dired-mode)
-	 (if (null arg) (not gnus-dired-mode)
-	   (> (prefix-numeric-value arg) 0)))
-    (when gnus-dired-mode
-      (add-minor-mode 'gnus-dired-mode "" gnus-dired-mode-map)
-      (save-current-buffer
-	(run-hooks 'gnus-dired-mode-hook)))))
+  :keymap gnus-dired-mode-map
+  (unless (derived-mode-p 'dired-mode)
+    (setq gnus-dired-mode nil)))
 
 ;;;###autoload
 (defun turn-on-gnus-dired-mode ()
--- a/lisp/gnus/gnus-draft.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/gnus-draft.el	Sun May 02 20:41:45 2010 -0400
@@ -35,20 +35,15 @@
 
 ;;; Draft minor mode
 
-(defvar gnus-draft-mode nil
-  "Minor mode for providing a draft summary buffers.")
-
-(defvar gnus-draft-mode-map nil)
-
-(unless gnus-draft-mode-map
-  (setq gnus-draft-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys gnus-draft-mode-map
-    "Dt" gnus-draft-toggle-sending
-    "e"  gnus-draft-edit-message ;; Use `B w' for `gnus-summary-edit-article'
-    "De" gnus-draft-edit-message
-    "Ds" gnus-draft-send-message
-    "DS" gnus-draft-send-all-messages))
+(defvar gnus-draft-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+     "Dt" gnus-draft-toggle-sending
+     "e"  gnus-draft-edit-message ;; Use `B w' for `gnus-summary-edit-article'
+     "De" gnus-draft-edit-message
+     "Ds" gnus-draft-send-message
+     "DS" gnus-draft-send-all-messages)
+    map))
 
 (defun gnus-draft-make-menu-bar ()
   (unless (boundp 'gnus-draft-menu)
@@ -61,20 +56,17 @@
        ["Send all messages" gnus-draft-send-all-messages t]
        ["Delete draft" gnus-summary-delete-article t]))))
 
-(defun gnus-draft-mode (&optional arg)
+(define-minor-mode gnus-draft-mode
   "Minor mode for providing a draft summary buffers.
 
 \\{gnus-draft-mode-map}"
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (when (set (make-local-variable 'gnus-draft-mode)
-	       (if (null arg) (not gnus-draft-mode)
-		 (> (prefix-numeric-value arg) 0)))
-      ;; Set up the menu.
-      (when (gnus-visual-p 'draft-menu 'menu)
-	(gnus-draft-make-menu-bar))
-      (add-minor-mode 'gnus-draft-mode " Draft" gnus-draft-mode-map)
-      (gnus-run-hooks 'gnus-draft-mode-hook))))
+  :lighter " Draft" :keymap gnus-draft-mode-map
+  (cond
+   ((not (derived-mode-p 'gnus-summary-mode)) (setq gnus-draft-mode nil))
+   (gnus-draft-mode
+    ;; Set up the menu.
+    (when (gnus-visual-p 'draft-menu 'menu)
+      (gnus-draft-make-menu-bar)))))
 
 ;;; Commands
 
--- a/lisp/gnus/gnus-ml.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/gnus-ml.el	Sun May 02 20:41:45 2010 -0400
@@ -33,24 +33,19 @@
 
 ;;; Mailing list minor mode
 
-(defvar gnus-mailing-list-mode nil
-  "Minor mode for providing mailing-list commands.")
-
-(defvar gnus-mailing-list-mode-map nil)
+(defvar gnus-mailing-list-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+      "\C-c\C-nh" gnus-mailing-list-help
+      "\C-c\C-ns" gnus-mailing-list-subscribe
+      "\C-c\C-nu" gnus-mailing-list-unsubscribe
+      "\C-c\C-np" gnus-mailing-list-post
+      "\C-c\C-no" gnus-mailing-list-owner
+      "\C-c\C-na" gnus-mailing-list-archive)
+    map))
 
 (defvar gnus-mailing-list-menu)
 
-(unless gnus-mailing-list-mode-map
-  (setq gnus-mailing-list-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys gnus-mailing-list-mode-map
-    "\C-c\C-nh" gnus-mailing-list-help
-    "\C-c\C-ns" gnus-mailing-list-subscribe
-    "\C-c\C-nu" gnus-mailing-list-unsubscribe
-    "\C-c\C-np" gnus-mailing-list-post
-    "\C-c\C-no" gnus-mailing-list-owner
-    "\C-c\C-na" gnus-mailing-list-archive))
-
 (defun gnus-mailing-list-make-menu-bar ()
   (unless (boundp 'gnus-mailing-list-menu)
     (easy-menu-define
@@ -88,21 +83,19 @@
       (gnus-message 1 "no list-post in this message."))))
 
 ;;;###autoload
-(defun gnus-mailing-list-mode (&optional arg)
+(define-minor-mode gnus-mailing-list-mode
   "Minor mode for providing mailing-list commands.
 
 \\{gnus-mailing-list-mode-map}"
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (when (set (make-local-variable 'gnus-mailing-list-mode)
-	       (if (null arg) (not gnus-mailing-list-mode)
-		 (> (prefix-numeric-value arg) 0)))
-      ;; Set up the menu.
-      (when (gnus-visual-p 'mailing-list-menu 'menu)
-	(gnus-mailing-list-make-menu-bar))
-      (add-minor-mode 'gnus-mailing-list-mode " Mailing-List"
-		      gnus-mailing-list-mode-map)
-      (gnus-run-hooks 'gnus-mailing-list-mode-hook))))
+  :lighter " Mailing-List"
+  :keymap gnus-mailing-list-mode-map
+  (cond
+   ((not (derived-mode-p 'gnus-summary-mode))
+    (setq gnus-mailing-list-mode nil))
+   (gnus-mailing-list-mode
+    ;; Set up the menu.
+    (when (gnus-visual-p 'mailing-list-menu 'menu)
+      (gnus-mailing-list-make-menu-bar)))))
 
 ;;; Commands
 
--- a/lisp/gnus/gnus-salt.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/gnus-salt.el	Sun May 02 20:41:45 2010 -0400
@@ -35,10 +35,6 @@
 ;;; gnus-pick-mode
 ;;;
 
-(defvar gnus-pick-mode nil
-  "Minor mode for providing a pick-and-read interface in Gnus
-summary buffers.")
-
 (defcustom gnus-pick-display-summary nil
   "*Display summary while reading."
   :type 'boolean
@@ -72,17 +68,15 @@
 
 ;;; Internal variables.
 
-(defvar gnus-pick-mode-map nil)
-
-(unless gnus-pick-mode-map
-  (setq gnus-pick-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys gnus-pick-mode-map
-    " " gnus-pick-next-page
-    "u" gnus-pick-unmark-article-or-thread
-    "." gnus-pick-article-or-thread
-    gnus-down-mouse-2 gnus-pick-mouse-pick-region
-    "\r" gnus-pick-start-reading))
+(defvar gnus-pick-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+      " " gnus-pick-next-page
+      "u" gnus-pick-unmark-article-or-thread
+      "." gnus-pick-article-or-thread
+      gnus-down-mouse-2 gnus-pick-mouse-pick-region
+      "\r" gnus-pick-start-reading)
+    map))
 
 (defun gnus-pick-make-menu-bar ()
   (unless (boundp 'gnus-pick-menu)
@@ -104,30 +98,30 @@
 	["Start reading" gnus-pick-start-reading t]
 	["Switch pick mode off" gnus-pick-mode gnus-pick-mode]))))
 
-(defun gnus-pick-mode (&optional arg)
+(define-minor-mode gnus-pick-mode
   "Minor mode for providing a pick-and-read interface in Gnus summary buffers.
 
 \\{gnus-pick-mode-map}"
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (if (not (set (make-local-variable 'gnus-pick-mode)
-		  (if (null arg) (not gnus-pick-mode)
-		    (> (prefix-numeric-value arg) 0))))
-	(remove-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
-      ;; Make sure that we don't select any articles upon group entry.
-      (set (make-local-variable 'gnus-auto-select-first) nil)
-      ;; Change line format.
-      (setq gnus-summary-line-format gnus-summary-pick-line-format)
-      (setq gnus-summary-line-format-spec nil)
-      (gnus-update-format-specifications nil 'summary)
-      (gnus-update-summary-mark-positions)
-      (add-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
-      (set (make-local-variable 'gnus-summary-goto-unread) 'never)
-      ;; Set up the menu.
-      (when (gnus-visual-p 'pick-menu 'menu)
-	(gnus-pick-make-menu-bar))
-      (add-minor-mode 'gnus-pick-mode " Pick" gnus-pick-mode-map)
-      (gnus-run-hooks 'gnus-pick-mode-hook))))
+  :lighter " Pick" :keymap gnus-pick-mode-map
+  (cond
+   ((not (derived-mode-p 'gnus-summary-mode)) (setq gnus-pick-mode nil))
+   ((not gnus-pick-mode)
+    ;; FIXME: a buffer-local minor mode removing globally from a hook??
+    (remove-hook 'gnus-message-setup-hook 'gnus-pick-setup-message))
+   (t
+    ;; Make sure that we don't select any articles upon group entry.
+    (set (make-local-variable 'gnus-auto-select-first) nil)
+    ;; Change line format.
+    (setq gnus-summary-line-format gnus-summary-pick-line-format)
+    (setq gnus-summary-line-format-spec nil)
+    (gnus-update-format-specifications nil 'summary)
+    (gnus-update-summary-mark-positions)
+    ;; FIXME: a buffer-local minor mode adding globally to a hook??
+    (add-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
+    (set (make-local-variable 'gnus-summary-goto-unread) 'never)
+    ;; Set up the menu.
+    (when (gnus-visual-p 'pick-menu 'menu)
+      (gnus-pick-make-menu-bar)))))
 
 (defun gnus-pick-setup-message ()
   "Make Message do the right thing on exit."
@@ -319,20 +313,14 @@
 ;;; gnus-binary-mode
 ;;;
 
-(defvar gnus-binary-mode nil
-  "Minor mode for providing a binary group interface in Gnus summary buffers.")
-
 (defvar gnus-binary-mode-hook nil
   "Hook run in summary binary mode buffers.")
 
-(defvar gnus-binary-mode-map nil)
-
-(unless gnus-binary-mode-map
-  (setq gnus-binary-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys
-      gnus-binary-mode-map
-    "g" gnus-binary-show-article))
+(defvar gnus-binary-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+      "g" gnus-binary-show-article)
+    map))
 
 (defun gnus-binary-make-menu-bar ()
   (unless (boundp 'gnus-binary-menu)
@@ -341,25 +329,20 @@
       '("Pick"
 	["Switch binary mode off" gnus-binary-mode t]))))
 
-(defun gnus-binary-mode (&optional arg)
+(define-minor-mode gnus-binary-mode
   "Minor mode for providing a binary group interface in Gnus summary buffers."
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (make-local-variable 'gnus-binary-mode)
-    (setq gnus-binary-mode
-	  (if (null arg) (not gnus-binary-mode)
-	    (> (prefix-numeric-value arg) 0)))
-    (when gnus-binary-mode
-      ;; Make sure that we don't select any articles upon group entry.
-      (make-local-variable 'gnus-auto-select-first)
-      (setq gnus-auto-select-first nil)
-      (make-local-variable 'gnus-summary-display-article-function)
-      (setq gnus-summary-display-article-function 'gnus-binary-display-article)
-      ;; Set up the menu.
-      (when (gnus-visual-p 'binary-menu 'menu)
-	(gnus-binary-make-menu-bar))
-      (add-minor-mode 'gnus-binary-mode " Binary" gnus-binary-mode-map)
-      (gnus-run-hooks 'gnus-binary-mode-hook))))
+  :lighter " Binary" :keymap gnus-binary-mode-map
+  (cond
+   ((not (derived-mode-p 'gnus-summary-mode)) (setq gnus-binary-mode nil))
+   (gnus-binary-mode
+    ;; Make sure that we don't select any articles upon group entry.
+    (make-local-variable 'gnus-auto-select-first)
+    (setq gnus-auto-select-first nil)
+    (make-local-variable 'gnus-summary-display-article-function)
+    (setq gnus-summary-display-article-function 'gnus-binary-display-article)
+    ;; Set up the menu.
+    (when (gnus-visual-p 'binary-menu 'menu)
+      (gnus-binary-make-menu-bar)))))
 
 (defun gnus-binary-display-article (article &optional all-header)
   "Run ARTICLE through the binary decode functions."
--- a/lisp/gnus/gnus-start.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/gnus-start.el	Sun May 02 20:41:45 2010 -0400
@@ -2960,6 +2960,8 @@
 
 (defun gnus-slave-mode ()
   "Minor mode for slave Gnusae."
+  ;; FIXME: gnus-slave-mode appears to never be set (i.e. it'll always be nil):
+  ;; Remove, or fix and use define-minor-mode.
   (add-minor-mode 'gnus-slave-mode " Slave" (make-sparse-keymap))
   (gnus-run-hooks 'gnus-slave-mode-hook))
 
@@ -3058,6 +3060,7 @@
       nil)
      (t
       (save-excursion
+        ;; FIXME: Shouldn't save-restriction be done after set-buffer?
 	(save-restriction
 	  (set-buffer nntp-server-buffer)
 	  (goto-char (point-min))
--- a/lisp/gnus/gnus-sum.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/gnus-sum.el	Sun May 02 20:41:45 2010 -0400
@@ -7237,33 +7237,21 @@
 
 ;;; Dead summaries.
 
-(defvar gnus-dead-summary-mode-map nil)
-
-(unless gnus-dead-summary-mode-map
-  (setq gnus-dead-summary-mode-map (make-keymap))
-  (suppress-keymap gnus-dead-summary-mode-map)
-  (substitute-key-definition
-   'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
-  (dolist (key '("\C-d" "\r" "\177" [delete]))
-    (define-key gnus-dead-summary-mode-map
-      key 'gnus-summary-wake-up-the-dead))
-  (dolist (key '("q" "Q"))
-    (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
-
-(defvar gnus-dead-summary-mode nil
-  "Minor mode for Gnus summary buffers.")
-
-(defun gnus-dead-summary-mode (&optional arg)
+(defvar gnus-dead-summary-mode-map
+  (let ((map (make-keymap)))
+    (suppress-keymap map)
+    (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
+    (dolist (key '("\C-d" "\r" "\177" [delete]))
+      (define-key map key 'gnus-summary-wake-up-the-dead))
+    (dolist (key '("q" "Q"))
+      (define-key map key 'bury-buffer))
+    map))
+
+(define-minor-mode gnus-dead-summary-mode
   "Minor mode for Gnus summary buffers."
-  (interactive "P")
-  (when (eq major-mode 'gnus-summary-mode)
-    (make-local-variable 'gnus-dead-summary-mode)
-    (setq gnus-dead-summary-mode
-	  (if (null arg) (not gnus-dead-summary-mode)
-	    (> (prefix-numeric-value arg) 0)))
-    (when gnus-dead-summary-mode
-      (add-minor-mode
-       'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
+  :lighter " Dead" :keymap gnus-dead-summary-mode-map
+  (unless (derived-mode-p 'gnus-summary-mode)
+    (setq gnus-dead-summary-mode nil)))
 
 (defun gnus-deaden-summary ()
   "Make the current summary buffer into a dead summary buffer."
--- a/lisp/gnus/gnus-topic.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/gnus-topic.el	Sun May 02 20:41:45 2010 -0400
@@ -1140,6 +1140,7 @@
 
 (defun gnus-topic-mode (&optional arg redisplay)
   "Minor mode for topicsifying Gnus group buffers."
+  ;; FIXME: Use define-minor-mode.
   (interactive (list current-prefix-arg t))
   (when (eq major-mode 'gnus-group-mode)
     (make-local-variable 'gnus-topic-mode)
--- a/lisp/gnus/gnus-undo.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/gnus-undo.el	Sun May 02 20:41:45 2010 -0400
@@ -59,6 +59,10 @@
   :group 'gnus-undo)
 
 (defcustom gnus-undo-mode nil
+  ;; FIXME: This is a buffer-local minor mode which requires running
+  ;; code upon activation/deactivation, so defining it as a defcustom
+  ;; doesn't seem very useful: setting it to non-nil via Customize
+  ;; probably won't do the right thing.
   "Minor mode for undoing in Gnus buffers."
   :type 'boolean
   :group 'gnus-undo)
@@ -77,17 +81,15 @@
 
 ;;; Minor mode definition.
 
-(defvar gnus-undo-mode-map nil)
-
-(unless gnus-undo-mode-map
-  (setq gnus-undo-mode-map (make-sparse-keymap))
-
-  (gnus-define-keys gnus-undo-mode-map
-    "\M-\C-_"     gnus-undo
-    "\C-_"        gnus-undo
-    "\C-xu"       gnus-undo
-    ;; many people are used to type `C-/' on X terminals and get `C-_'.
-    [(control /)] gnus-undo))
+(defvar gnus-undo-mode-map
+  (let ((map (make-sparse-keymap)))
+    (gnus-define-keys map
+      "\M-\C-_"     gnus-undo
+      "\C-_"        gnus-undo
+      "\C-xu"       gnus-undo
+      ;; many people are used to type `C-/' on X terminals and get `C-_'.
+      [(control /)] gnus-undo)
+    map))
 
 (defun gnus-undo-make-menu-bar ()
   ;; This is disabled for the time being.
@@ -96,24 +98,19 @@
       (cons "Undo" 'gnus-undo-actions)
       [menu-bar file whatever])))
 
-(defun gnus-undo-mode (&optional arg)
+(define-minor-mode gnus-undo-mode
   "Minor mode for providing `undo' in Gnus buffers.
 
 \\{gnus-undo-mode-map}"
-  (interactive "P")
-  (set (make-local-variable 'gnus-undo-mode)
-       (if (null arg) (not gnus-undo-mode)
-	 (> (prefix-numeric-value arg) 0)))
+  :keymap gnus-undo-mode-map
   (set (make-local-variable 'gnus-undo-actions) nil)
   (set (make-local-variable 'gnus-undo-boundary) t)
   (when gnus-undo-mode
     ;; Set up the menu.
     (when (gnus-visual-p 'undo-menu 'menu)
       (gnus-undo-make-menu-bar))
-    (add-minor-mode 'gnus-undo-mode "" gnus-undo-mode-map)
     (gnus-make-local-hook 'post-command-hook)
-    (add-hook 'post-command-hook 'gnus-undo-boundary nil t)
-    (gnus-run-hooks 'gnus-undo-mode-hook)))
+    (add-hook 'post-command-hook 'gnus-undo-boundary nil t)))
 
 ;;; Interface functions.
 
--- a/lisp/gnus/mml.el	Sun May 02 12:32:18 2010 -0700
+++ b/lisp/gnus/mml.el	Sun May 02 20:41:45 2010 -0400
@@ -898,8 +898,7 @@
     ;; Determine type and stuff.
     (unless (stringp (car handle))
       (unless (setq textp (equal (mm-handle-media-supertype handle) "text"))
-	(save-excursion
-	  (set-buffer (setq buffer (mml-generate-new-buffer " *mml*")))
+	(with-current-buffer (setq buffer (mml-generate-new-buffer " *mml*"))
 	  (if (eq (mail-content-type-get (mm-handle-type handle) 'charset)
 		  'gnus-decoded)
 	      ;; A part that mm-uu dissected from a non-MIME message
@@ -1126,25 +1125,18 @@
      ,@(if (featurep 'xemacs) '(t)
 	 '(:help "Display the EasyPG manual"))]))
 
-(defvar mml-mode nil
-  "Minor mode for editing MML.")
-
-(defun mml-mode (&optional arg)
+(define-minor-mode mml-mode
   "Minor mode for editing MML.
 MML is the MIME Meta Language, a minor mode for composing MIME articles.
 See Info node `(emacs-mime)Composing'.
 
 \\{mml-mode-map}"
-  (interactive "P")
-  (when (set (make-local-variable 'mml-mode)
-	     (if (null arg) (not mml-mode)
-	       (> (prefix-numeric-value arg) 0)))
-    (add-minor-mode 'mml-mode " MML" mml-mode-map)
+  :lighter " MML" :keymap mml-mode-map
+  (when mml-mode
     (easy-menu-add mml-menu mml-mode-map)
     (when (boundp 'dnd-protocol-alist)
       (set (make-local-variable 'dnd-protocol-alist)
-	   (append mml-dnd-protocol-alist dnd-protocol-alist)))
-    (run-hooks 'mml-mode-hook)))
+	   (append mml-dnd-protocol-alist dnd-protocol-alist)))))
 
 ;;;
 ;;; Helper functions for reading MIME stuff from the minibuffer and