This function reproduces the problem
(defun show-bug ()
(interactive)
(let ((coding-system-for-read 'no-conversion))
(find-file "/tmp/foo"))
(erase-buffer)
(insert "\e$BF|K\\8l\e(B\n")
(save-buffer)
(insert "i live\n")
(do-auto-save))
Now cd to /tmp and diff /tmp/foo and its autosave file. I
advise piping the result through cat -v so you can see the
control characters. Each escape character in the file has
been doubled. Looking at the XEmacs code, this seems to be
intentional, though I don't know why.
Here's a patch. Recommended for the 21.1 code line because this
problem corrupts autosave files of mail folders that have
ISO-2022-JP encoded messages in them. I haven't looked at the
development code line so I don't know if the patch is approrpiate
there. I also changed the MULE #ifdef to FILE_CODING because
maintaining the current coding system looks like the right thing
to do in that context also.
*** src/fileio.c 2001/10/31 04:21:24 1.1
--- src/fileio.c 2001/10/31 04:22:01
***************
*** 3825,3832 ****
return
/* !!#### need to deal with this 'escape-quoted everywhere */
Fwrite_region_internal (Qnil, Qnil, a, Qnil, Qlambda, Qnil,
! #ifdef MULE
! Qescape_quoted
#else
Qnil
#endif
--- 3825,3832 ----
return
/* !!#### need to deal with this 'escape-quoted everywhere */
Fwrite_region_internal (Qnil, Qnil, a, Qnil, Qlambda, Qnil,
! #ifdef FILE_CODING
! current_buffer->buffer_file_coding_system
#else
Qnil
#endif