>>>> In <yosu7kvpbwwh.fsf(a)jpl.org>
>>>> Katsumi Yamaoka <yamaoka(a)jpl.org> wrote:
KY> Dear XEmacs developers,
KY> In latest 21.5, I found a serious problem that the function
KY> `insert-file-contents' will not refer to the coding-system magic
KY> cookie in the beginning of a file as follows:
KY> ;;; -*- mode: emacs-lisp; coding: iso-2022-7bit -*-
Sadly, I noticed that whole versions of XEmacs with mule do not
handle the coding-system magic cookie. FSF Emacs shows HELLO
file correctly with the following code, but XEmacs does not.
(let* ((file "/tmp/TESTING")
(buffer (get-file-buffer file)))
(when buffer
(save-excursion
(set-buffer buffer)
(set-buffer-modified-p nil)
(kill-buffer buffer)))
(when (file-exists-p file)
(delete-file file))
(setq buffer (get-buffer-create "*testing*"))
(save-excursion
(set-buffer buffer)
(erase-buffer)
(insert "@ -*- coding: iso-2022-7bit -*-\n")
(let ((coding-system-for-read 'iso-2022-7bit))
(insert-file-contents (expand-file-name "HELLO" data-directory)))
(let ((coding-system-for-write 'iso-2022-7bit))
(write-region (point-min) (point-max) file)))
(kill-buffer buffer)
(let (coding-system-for-read
insert-file-contents-pre-hook
file-coding-system-alist
buffer-file-coding-system-for-read)
(find-file-other-window file)))
KY> Here is an emergency patch for it. I will take back this patch
KY> if there is a better way.
I made an another patch for the latest 21.5 CVS. I believe that
it is better than the last one. Could you please examine if it
is in place or not?
2001-08-28 Katsumi Yamaoka <yamaoka(a)jpl.org>
* files.el (find-coding-system-magic-cookie-in-file): Use
`insert-file-contents-internal' instead of `insert-file-contents'.
2001-08-27 Katsumi Yamaoka <yamaoka(a)jpl.org>
* code-files.el (insert-file-contents): Use
`find-coding-system-magic-cookie-in-file'.
--- code-files.el~ Fri May 4 22:42:00 2001
+++ code-files.el Tue Aug 28 07:05:37 2001
@@ -329,7 +329,8 @@
3. The matching value for this filename from
`file-coding-system-alist', if any.
4. `buffer-file-coding-system-for-read', if non-nil.
-5. The coding system 'raw-text.
+5. The result of `find-coding-system-magic-cookie-in-file', if non-nil.
+6. The coding system 'raw-text.
If a local value for `buffer-file-coding-system' in the current buffer
does not exist, it is set to the coding system which was actually used
@@ -358,6 +359,11 @@
;; #4.
buffer-file-coding-system-for-read
;; #5.
+ (let ((codesys
+ (find-coding-system-magic-cookie-in-file filename)))
+ (when codesys
+ (intern codesys)))
+ ;; #6.
'raw-text))
(if (consp coding-system)
(setq return-val coding-system)
--- files.el~ Sun Jun 10 10:42:23 2001
+++ files.el Tue Aug 28 07:05:37 2001
@@ -1723,8 +1723,7 @@
ISO 2022 encoding of most non-ASCII charsets."
(save-excursion
(with-temp-buffer
- (let ((coding-system-for-read 'raw-text))
- (insert-file-contents file nil 1 3001))
+ (insert-file-contents-internal file nil 0 3000 nil 'raw-text)
(goto-char (point-min))
(or (and (looking-at
"^[^\n]*-\\*-[^\n]*coding: \\([^ \t\n;]+\\)[^\n]*-\\*-")
Regards,
--
Katsumi Yamaoka <yamaoka(a)jpl.org>