diff lisp/view.el @ 108220:0b37f86b040e

Use define-minor-mode where applicable. * mh-show.el (mh-showing-mode): Move function to mh-e.el. * mh-e.el (mh-showing-mode): * url-dired.el (url-dired-minor-mode): * org-table.el (orgtbl-mode): * view.el (view-mode): * type-break.el (type-break-query-mode) (type-break-mode-line-message-mode): * textmodes/reftex.el (reftex-mode): * term/vt100.el (vt100-wide-mode): * tar-mode.el (tar-subfile-mode): * savehist.el (savehist-mode): * ibuf-ext.el (ibuffer-auto-mode): * composite.el (auto-composition-mode): * progmodes/vhdl-mode.el (vhdl-electric-mode, vhdl-stutter-mode): Use define-minor-mode. (vhdl-mode): Use static mode-line format. (vhdl-mode-line-update): Delete. (vhdl-create-mode-menu, vhdl-activate-customizations) (vhdl-hs-minor-mode): Don't bother calling it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 02 May 2010 22:29:46 -0400
parents 1721e4658521
children 417b1e4d63cd
line wrap: on
line diff
--- a/lisp/view.el	Sun May 02 19:23:42 2010 -0700
+++ b/lisp/view.el	Sun May 02 22:29:46 2010 -0400
@@ -161,14 +161,6 @@
   "Overlay used to display where a search operation found its match.
 This is local in each buffer, once it is used.")
 (make-variable-buffer-local 'view-overlay)
-
-(unless (assq 'view-mode minor-mode-alist)
-  (setq minor-mode-alist
-	(cons (list 'view-mode
-		    (propertize " View"
-				'local-map mode-line-minor-mode-keymap
-				'help-echo "mouse-3: minor mode menu"))
-	      minor-mode-alist)))
 
 ;; Define keymap inside defvar to make it easier to load changes.
 ;; Some redundant "less"-like key bindings below have been commented out.
@@ -230,10 +222,6 @@
     (define-key map "?" 'describe-mode)	; Maybe do as less instead? See above.
     (define-key map "h" 'describe-mode)
     map))
-
-(or (assq 'view-mode minor-mode-map-alist)
-    (setq minor-mode-map-alist
-	  (cons (cons 'view-mode view-mode-map) minor-mode-map-alist)))
 
 ;;; Commands that enter or exit view mode.
 
@@ -393,7 +381,7 @@
 		     exit-action)))
 
 ;;;###autoload
-(defun view-mode (&optional arg)
+(define-minor-mode view-mode
   ;; In the following documentation string we have to use some explicit key
   ;; bindings instead of using the \\[] construction.  The reason for this
   ;; is that most commands have more than one key binding.
@@ -473,11 +461,8 @@
 then \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] will return to that buffer.
 
 Entry to view-mode runs the normal hook `view-mode-hook'."
-  (interactive "P")
-  (unless (and arg			; Do nothing if already OK.
-	       (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode)))
-    (if view-mode (view-mode-disable)
-      (view-mode-enable))))
+  :lighter " View" :keymap view-mode-map
+  (if view-mode (view-mode-enable) (view-mode-disable)))
 
 (defun view-mode-enable ()
   "Turn on View mode."