diff lisp/modes/image-mode.el @ 169:15872534500d r20-3b11

Import from CVS: tag r20-3b11
author cvs
date Mon, 13 Aug 2007 09:46:53 +0200
parents 85ec50267440
children 78f53ef88e17
line wrap: on
line diff
--- a/lisp/modes/image-mode.el	Mon Aug 13 09:45:48 2007 +0200
+++ b/lisp/modes/image-mode.el	Mon Aug 13 09:46:53 2007 +0200
@@ -4,7 +4,7 @@
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Created: 1997/6/27
-;; Version: $Id: image-mode.el,v 1.1 1997/06/29 23:12:55 steve Exp $
+;; Version: image-mode.el,v 20.3.1.2 1997/07/01 17:29:44 morioka Exp
 ;; Keywords: image, graphics
 
 ;; This file is part of XEmacs.
@@ -123,6 +123,24 @@
   (kill-buffer (current-buffer))
   )
 
+(defun image-maybe-restore ()
+  "Restore buffer from file if it is decoded as `buffer-file-format'."
+  (when (and buffer-file-format
+	     buffer-file-name)
+    (setq buffer-read-only nil)
+    (erase-buffer)
+    (map-extents (function
+		  (lambda (extent maparg)
+		    (delete-extent extent)
+		    )) nil (point-min)(point-min))
+    (setq buffer-file-format nil)
+    (insert-file-contents-literally buffer-file-name)
+    (set-buffer-modified-p nil)
+    ))
+
+(add-hook 'change-major-mode-hook 'image-maybe-restore)
+
+
 ;;;###autoload
 (defun image-mode (&optional arg)
   "\\{image-mode-map}"