changeset 18268:a42f063f003b

Don't globally add to change-major-mode-hook. (view-mode-enable): Add to change-major-mode-hook locally here. (view-mode-disable): Remove from it locally here.
author Richard M. Stallman <rms@gnu.org>
date Mon, 16 Jun 1997 06:55:37 +0000
parents 29c37882ee1f
children 888bfd80db2c
files lisp/view.el
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/view.el	Mon Jun 16 06:24:22 1997 +0000
+++ b/lisp/view.el	Mon Jun 16 06:55:37 1997 +0000
@@ -187,10 +187,6 @@
     (setq minor-mode-map-alist
 	  (cons (cons 'view-mode view-mode-map) minor-mode-map-alist)))
 
-;; Always leave view mode before changing major mode.
-;; This is to guarantee that the buffer-read-only variable is restored.
-(add-hook 'change-major-mode-hook 'view-mode-disable)
-
 ;;; Commands that enter or exit view mode.
 
 ;;;###autoload
@@ -399,6 +395,10 @@
 
 (defun view-mode-enable ()
   "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)
 	view-half-page-size (or view-half-page-size (/ (view-window-size) 2))
@@ -415,6 +415,7 @@
 
 (defun view-mode-disable ()
   "Turn off View mode."
+  (remove-hook 'change-major-mode-hook 'view-mode-disable t)
   (and view-overlay (delete-overlay view-overlay))
   (setq view-mode nil
 	Helper-return-blurb view-old-Helper-return-blurb