lisp/cedet/semantic/db-typecache.el (semanticdb-typecache)
[bpt/emacs.git] / lisp / image-mode.el
index 78b4ab5..b751652 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)
@@ -323,7 +321,6 @@ You can use \\<image-mode-map>\\[image-toggle-display]
 to toggle between display as an image and display as text."
   (interactive)
   (kill-all-local-variables)
-  (setq mode-name "Image[text]")
   (setq major-mode 'image-mode)
   ;; Use our own bookmarking function for images.
   (set (make-local-variable 'bookmark-make-record-function)
@@ -333,13 +330,17 @@ 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 (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
+             image-type (plist-get (cdr (image-get-display-property)) :type)))
+    (setq image-type "text")
+    (use-local-map image-mode-text-map))
+  (setq mode-name (format "Image[%s]" image-type))
   (run-mode-hooks 'image-mode-hook)
   (if (display-images-p)
       (message "%s" (concat
@@ -358,15 +359,21 @@ See the command `image-mode' for more information on this mode."
   :version "22.1"
   (if (not image-minor-mode)
       (image-toggle-display-text)
-    (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 ")
-                         (if (image-get-display-property)
-                             "text" "an image") "."))))
+    (if (display-images-p)
+       (if (not (image-get-display-property))
+           (image-toggle-display)
+         (setq cursor-type nil truncate-lines t
+               image-type (plist-get (cdr (image-get-display-property)) :type)))
+      (setq image-type "text")
+      (use-local-map image-mode-text-map))
+    (if (display-images-p)
+       (message "%s" (concat
+                      (substitute-command-keys
+                       "Type \\[image-toggle-display] to view the image as ")
+                      (if (image-get-display-property)
+                          "text" "an image") ".")))))
 
 ;;;###autoload
 (defun image-mode-maybe ()
@@ -450,8 +457,9 @@ and showing the image as an image."
           (buffer-undo-list t)
           (modified (buffer-modified-p)))
       (image-refresh image)
-      (add-text-properties (point-min) (point-max) props)
-      (set-buffer-modified-p modified)
+      (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file
+       (add-text-properties (point-min) (point-max) props)
+       (restore-buffer-modified-p modified))
       ;; Inhibit the cursor when the buffer contains only an image,
       ;; because cursors look very strange on top of images.
       (setq cursor-type nil)
@@ -466,7 +474,7 @@ and showing the image as an image."
          (setq mode-name (format "Image[%s]" type)))
       (if (called-interactively-p)
          (message "Repeat this command to go back to displaying the file as text")))))
-
+\f
 ;;; Support for bookmark.el
 (declare-function bookmark-make-record-default "bookmark"
                   (&optional point-only))
@@ -478,8 +486,6 @@ and showing the image as an image."
          `((image-type . ,image-type)
            (handler    . image-bookmark-jump))))
 
-
-
 ;;;###autoload
 (defun image-bookmark-jump (bmk)
   ;; This implements the `handler' function interface for record type
@@ -487,7 +493,7 @@ and showing the image as an image."
   (prog1 (bookmark-default-handler bmk)
     (when (not (string= image-type (bookmark-prop-get bmk 'image-type)))
       (image-toggle-display))))
-
+\f
 (provide 'image-mode)
 
 ;; arch-tag: b5b2b7e6-26a7-4b79-96e3-1546b5c4c6cb