]> code.delx.au - gnu-emacs/blobdiff - lisp/view.el
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[gnu-emacs] / lisp / view.el
index 41cb975228881f76595a954bd71e428ee0327438..5a28415ec7a2c8fa31b8570e2c8a8e7216b8bb6d 100644 (file)
@@ -1,7 +1,7 @@
 ;;; view.el --- peruse file or buffer without editing
 
-;; Copyright (C) 1985, 1989, 1994-1995, 1997, 2000-2012
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1989, 1994-1995, 1997, 2000-2013 Free Software
+;; Foundation, Inc.
 
 ;; Author: K. Shane Hartman
 ;; Maintainer: Inge Frick <inge@nada.kth.se>
@@ -463,8 +463,9 @@ Entry to view-mode runs the normal hook `view-mode-hook'."
   :lighter " View" :keymap view-mode-map
   (if view-mode (view-mode-enable) (view-mode-disable)))
 \f
-(defun view-mode-enable ()
-  "Turn on View mode."
+(defun view-mode-enable (&optional run-view-mode-hook)
+  "Turn on View mode.
+Run `view-mode-hook' when RUN-VIEW-MODE-HOOK is non-nil."
   ;; 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 nil t)
@@ -482,7 +483,8 @@ Entry to view-mode runs the normal hook `view-mode-hook'."
                        (file-name-nondirectory (buffer-file-name))
                      (buffer-name)))))
   (force-mode-line-update)
-  (run-hooks 'view-mode-hook))
+  (when run-view-mode-hook
+    (run-hooks 'view-mode-hook)))
 
 (defun view-mode-disable ()
   "Turn off View mode."
@@ -513,6 +515,7 @@ that can be added see the RETURN-TO-ALIST argument of the
 function `view-mode-exit'.  If `view-return-to-alist' contains an
 entry for the selected window, purge that entry from
 `view-return-to-alist' before adding ITEM."
+  (declare (obsolete "this function has no effect." "24.1"))
   (with-current-buffer buffer
     (when view-return-to-alist
       (let* ((list view-return-to-alist)
@@ -535,7 +538,6 @@ entry for the selected window, purge that entry from
     (when item
       (setq view-return-to-alist
            (cons item view-return-to-alist)))))
-(make-obsolete 'view-return-to-alist-update "this function has no effect." "24.1")
 
 ;;;###autoload
 (defun view-mode-enter (&optional quit-restore exit-action)
@@ -560,7 +562,7 @@ This function runs the normal hook `view-mode-hook'."
     (setq view-exit-action exit-action))
 
   (unless view-mode
-    (view-mode-enable)
+    (view-mode-enable t)
     (force-mode-line-update)
     (unless view-inhibit-help-message
       (message "%s"