]> code.delx.au - gnu-emacs/commitdiff
Don't run view-mode-hook twice when calling view-mode (Bug#13315).
authorMartin Rudalics <rudalics@gmx.at>
Tue, 1 Jan 2013 11:02:14 +0000 (12:02 +0100)
committerMartin Rudalics <rudalics@gmx.at>
Tue, 1 Jan 2013 11:02:14 +0000 (12:02 +0100)
* view.el (view-mode-enable): New argument run-view-mode-hook.
Run view-mode-hook only when it's non-nil (Bug#13315).
(view-mode-enter): Call view-mode-enable with run-view-mode-hook
argument t.

lisp/ChangeLog
lisp/view.el

index 7e9e9d7738e8fca7b2c3d67b5780cd822f61fee4..e4ecda0d7892fb3eca9eb8d49395ffdca441e9ca 100644 (file)
@@ -1,3 +1,10 @@
+2013-01-01  Martin Rudalics  <rudalics@gmx.at>
+
+       * view.el (view-mode-enable): New argument run-view-mode-hook.
+       Run view-mode-hook only when it's non-nil (Bug#13315).
+       (view-mode-enter): Call view-mode-enable with run-view-mode-hook
+       argument t.
+
 2012-12-31  Jürgen Hötzel  <juergen@archlinux.org>
 
        * net/tramp-adb.el (tramp-adb-maybe-open-connection): Handle errors
index 7ed42bf7ddc865c1573e588c3da8fecc6de14b65..329d3738edc1f89cd0ec44c51f7ee6e6cb3819d2 100644 (file)
@@ -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."
@@ -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"