# HG changeset patch # User aidan # Date 1112969220 0 # Node ID 5427b625d5cc86aca7c9618db5a8401e3ca156eb # Parent 834cce9b23601f1aa6a4d24d3357047ac2341aa4 [xemacs-hg @ 2005-04-08 14:06:58 by aidan] Make find-file with prefix-arg on a nonexistent file behave properly. diff -r 834cce9b2360 -r 5427b625d5cc lisp/ChangeLog --- a/lisp/ChangeLog Thu Apr 07 21:51:47 2005 +0000 +++ b/lisp/ChangeLog Fri Apr 08 14:07:00 2005 +0000 @@ -1,3 +1,8 @@ +2005-04-08 Aidan Kehoe + + * files.el (find-file): Honour the coding system argument even in + the case where we're creating a new file. + 2005-04-04 Steve Youngs * files.el (backup-buffer): Write "%backup%~" in diff -r 834cce9b2360 -r 5427b625d5cc lisp/files.el --- a/lisp/files.el Thu Apr 07 21:51:47 2005 +0000 +++ b/lisp/files.el Fri Apr 08 14:07:00 2005 +0000 @@ -864,12 +864,20 @@ (read-coding-system "Coding system: ")) t)) (if codesys - (let ((coding-system-for-read - (get-coding-system codesys))) - (let ((value (find-file-noselect filename nil nil wildcards))) - (if (listp value) - (mapcar 'switch-to-buffer (nreverse value)) - (switch-to-buffer value)))) + (let* ((coding-system-for-read (get-coding-system codesys)) + (value (find-file-noselect filename nil nil wildcards)) + (bufname (if (listp value) (car (nreverse value)) value))) + ;; If a user explicitly specified the coding system with a prefix + ;; argument when opening a nonexistent file, insert-file-contents + ;; hasn't preserved that coding system as the local + ;; buffer-file-coding-system. Do that ourselves. + (unless (and bufname + (file-exists-p (buffer-file-name bufname)) + (local-variable-p 'buffer-file-coding-system bufname)) + (save-excursion + (set-buffer bufname) + (setq buffer-file-coding-system coding-system-for-read))) + (switch-to-buffer bufname)) (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) (mapcar 'switch-to-buffer (nreverse value))