summaryrefslogtreecommitdiff
path: root/lisp/view.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-06-16 06:55:37 +0000
committerRichard M. Stallman <rms@gnu.org>1997-06-16 06:55:37 +0000
commit439d6fd6e6e48f85c8f492566ca2e4fa641004fc (patch)
treed5d356a59266fb596a7a173513828aafda5ddab4 /lisp/view.el
parentef82d5c9be85e1e18bfbae15406058ad6258e1d9 (diff)
downloademacs-439d6fd6e6e48f85c8f492566ca2e4fa641004fc.tar.gz
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.
Diffstat (limited to 'lisp/view.el')
-rw-r--r--lisp/view.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/lisp/view.el b/lisp/view.el
index 8ac8377e476..a0fc23d0182 100644
--- a/lisp/view.el
+++ b/lisp/view.el
@@ -187,10 +187,6 @@ This is local in each buffer, once it is used.")
(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 @@ Entry to view-mode runs the normal hook `view-mode-hook'."
(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 @@ Entry to view-mode runs the normal hook `view-mode-hook'."
(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