Subject: Re: bug#8047: 23.2.94; Auto image mode breaks C-x C-w

From: Eli Zaretskii <[email-masked]>
Date: Wed, 16 Feb 2011 22:03:06 +0200

> Date: Wed, 16 Feb 2011 19:57:19 +0200
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> > As for the actual fix, maybe require-final-newline should be ignored
> > when the encoding is `binary'?
> 
> That's what I have in mind; feel free to beat me to it, because I
> don't buy the argument that since this was so in Emacs 22, we need to
> live with it until 24.1.

However, since emacs-23 is in deep freeze, I would like to suggest an
even more conservative change, see below.  This one affects only
image-mode buffers that display image files.

Chong, is this okay to install on the release branch, even though the
bug predates Emacs 23.2?

--- lisp/image-mode.el~	2011-02-15 21:32:39.565125000 +0200
+++ lisp/image-mode.el	2011-02-16 21:55:04.190125000 +0200
@@ -507,6 +507,9 @@ (defun image-toggle-display-image ()
     ;; This just makes the arrow displayed in the right fringe
     ;; area look correct when the image is wider than the window.
     (setq truncate-lines t)
+    ;; Disable adding a newline at the end of the image file when it
+    ;; is written with, e.g., C-x C-w.
+    (setq find-file-literally t)
     ;; Allow navigation of large images
     (set (make-local-variable 'auto-hscroll-mode) nil)
     (setq image-type type)