Mercurial > hg > xemacs-beta
diff lisp/files.el @ 2718:5427b625d5cc
[xemacs-hg @ 2005-04-08 14:06:58 by aidan]
Make find-file with prefix-arg on a nonexistent file behave properly.
author | aidan |
---|---|
date | Fri, 08 Apr 2005 14:07:00 +0000 |
parents | 54fd042e254c |
children | fd1acd2f457a |
line wrap: on
line diff
--- 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))