(flyspell-post-command-hook): Do nothing unless flyspell-mode is enabled.
[bpt/emacs.git] / lisp / image-mode.el
index 00f2225..8cdf22a 100644 (file)
@@ -1,6 +1,6 @@
 ;;; image-mode.el --- support for visiting image files
 ;;
-;; Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 ;;
 ;; Author: Richard Stallman <rms@gnu.org>
 ;; Keywords: multimedia
@@ -290,11 +290,9 @@ This variable is used to display the current image type in the mode line.")
   (let ((map (make-sparse-keymap)))
     (suppress-keymap map)
     (define-key map "q"         'quit-window)
-    ;;
     (define-key map "\C-c\C-c" 'image-toggle-display)
     (define-key map (kbd "SPC")       'image-scroll-up)
     (define-key map (kbd "DEL")       'image-scroll-down)
-    ;;
     (define-key map [remap forward-char] 'image-forward-hscroll)
     (define-key map [remap backward-char] 'image-backward-hscroll)
     (define-key map [remap previous-line] 'image-previous-line)
@@ -333,13 +331,14 @@ to toggle between display as an image and display as text."
   (image-mode-setup-winprops)
 
   (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
-  (if (and (display-images-p)
-          (not (image-get-display-property)))
-      (image-toggle-display)
-    ;; Set next vars when image is already displayed but local
-    ;; variables were cleared by kill-all-local-variables
-    (use-local-map image-mode-map)
-    (setq cursor-type nil truncate-lines t))
+  (if (display-images-p)
+      (if (not (get-text-property (point-min) 'display))
+         (image-toggle-display)
+       ;; Set next vars when image is already displayed but local
+       ;; variables were cleared by kill-all-local-variables
+       (use-local-map image-mode-map)
+       (setq cursor-type nil truncate-lines t))
+    (use-local-map image-mode-text-map))
   (run-mode-hooks 'image-mode-hook)
   (if (display-images-p)
       (message "%s" (concat
@@ -361,6 +360,7 @@ See the command `image-mode' for more information on this mode."
     (if (image-get-display-property)
        (setq cursor-type nil truncate-lines t)
       (setq image-type "text"))
+    (image-mode-setup-winprops)
     (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t)
     (message "%s" (concat (substitute-command-keys
                           "Type \\[image-toggle-display] to view the image as ")