]> code.delx.au - gnu-emacs/blobdiff - lisp/view.el
(c-mode-abbrev-table, c++-mode-abbrev-table, objc-mode-abbrev-table)
[gnu-emacs] / lisp / view.el
index e6024601679698695a145fa22ac37ffa334b6dac..0932be3903bd3beb8dcb6c617ae7b3df264fad3a 100644 (file)
@@ -1,10 +1,11 @@
-;;; view.el --- peruse file or buffer without editing.
+;;; view.el --- peruse file or buffer without editing
 
-;; Copyright (C) 1985, 1989, 1994, 1995, 1997, 2000
+;; Copyright (C) 1985, 1989, 1994, 1995, 1997, 2000, 2001
 ;;   Free Software Foundation, Inc.
 
 ;; Author: K. Shane Hartman
 ;; Maintainer: Inge Frick <inge@nada.kth.se>
+;; Keywords: files
 
 ;; This file is part of GNU Emacs.
 
@@ -157,9 +158,13 @@ that use View mode automatically.")
 This is local in each buffer, once it is used.")
 (make-variable-buffer-local 'view-overlay)
 
-(or (assq 'view-mode minor-mode-alist)
-    (setq minor-mode-alist
-         (cons '(view-mode " View") minor-mode-alist)))
+(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.
@@ -436,7 +441,6 @@ Entry to view-mode runs the normal hook `view-mode-hook'."
   "Turn on View mode."
   ;; Always leave view mode before changing major mode.
   ;; This is to guarantee that the buffer-read-only variable is restored.
-  (make-local-hook 'change-major-mode-hook)
   (add-hook 'change-major-mode-hook 'view-mode-disable nil t)
   (setq view-mode t
        view-page-size (view-page-size-default view-page-size)
@@ -458,6 +462,14 @@ Entry to view-mode runs the normal hook `view-mode-hook'."
   (remove-hook 'change-major-mode-hook 'view-mode-disable t)
   (and view-overlay (delete-overlay view-overlay))
   (force-mode-line-update)
+  ;; Calling toggle-read-only while View mode is enabled
+  ;; sets view-read-only to t as a buffer-local variable
+  ;; after exiting View mode.  That arranges that the next toggle-read-only
+  ;; will reenable View mode.
+  ;; Cancelling View mode in any other way should cancel that, too,
+  ;; so that View mode stays off if toggle-read-only is called.
+  (if (local-variable-p 'view-read-only)
+      (kill-local-variable 'view-read-only))
   (setq view-mode nil
        Helper-return-blurb view-old-Helper-return-blurb)
   (if buffer-read-only