Mercurial > hg > xemacs-beta
diff lisp/code-files.el @ 4650:8905163c49c5
#'find-file: set b-f-c-s even on error (cf. non-existent files),
handle undecided coding-systems passed back from
#'insert-file-contents-internal better.
tests/ChangeLog addition:
2009-07-13 Aidan Kehoe <kehoea@parhasard.net>
* automated/mule-tests.el:
Now that find-file on a nonexistent path gives a modified buffer,
we want to set this kind of buffer to be non-modified here before
killing it.
lisp/ChangeLog addition:
2009-07-13 Aidan Kehoe <kehoea@parhasard.net>
* code-files.el (insert-file-contents):
Set the buffer coding system even on error; especially important
when dealing with nonexistent files.
If the `coding-system' property of an undecided coding system is
itself undecided, don't use that as a value for
buffer-file-coding-system.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 13 Jul 2009 20:45:26 +0100 |
parents | e4ed58cb0e5b |
children | 308d34e9f07d |
line wrap: on
line diff
--- a/lisp/code-files.el Sun Jul 12 14:20:55 2009 +0100 +++ b/lisp/code-files.el Mon Jul 13 20:45:26 2009 +0100 @@ -439,6 +439,33 @@ 'used-codesys)) )) (file-error + ;; If we error, which we may if the file does not exist, we still + ;; want to set the buffer-file-coding-system if that is + ;; appropriate: + (when (eq 'undecided (coding-system-type coding-system)) + (setq used-codesys (coding-system-property coding-system + 'coding-system)) + (if (and used-codesys + (not (eq 'undecided (coding-system-type used-codesys)))) + ;; If this property is available, and not undecided, it should + ;; be a coding system that we can use to write a file (as + ;; opposed to the true undecided coding system, which trashes + ;; non-Latin-1 on writing). It might just be the value of + ;; coding-system passed to #'insert-file-contents-internal. + (setq coding-system used-codesys) + ;; Otherwise, take the value normally specified by the + ;; language environment: + (setq coding-system (default-value + 'buffer-file-coding-system)))) + (if (local-variable-p 'buffer-file-coding-system + (current-buffer)) + (set-buffer-file-coding-system + (subsidiary-coding-system + buffer-file-coding-system + (coding-system-eol-type coding-system)) t t) + (set-buffer-file-coding-system coding-system t t)) + (setq buffer-file-coding-system-when-loaded + coding-system) (run-hook-with-args 'insert-file-contents-error-hook filename visit err) (signal (car err) (cdr err)))) @@ -449,17 +476,19 @@ (unless (zerop (buffer-size)) (warn "%s: autodetection failed: setting to default." (file-name-nondirectory (buffer-file-name)))) - (setq coding-system - (or - ;; If this property is available, it will be a coding - ;; system that we can use to write a file (as opposed to - ;; the true undecided coding system, which trashes - ;; non-Latin-1 on writing). It might just be the value of - ;; coding-system passed to #'insert-file-contents-internal. - (coding-system-property coding-system 'coding-system) - ;; Otherwise, take the value normally specified by the - ;; language environment: - (default-value 'buffer-file-coding-system)))) + (setq used-codesys (coding-system-property coding-system + 'coding-system)) + (if (and used-codesys + (not (eq 'undecided (coding-system-type used-codesys)))) + ;; If this property is available, and not undecided, it should + ;; be a coding system that we can use to write a file (as + ;; opposed to the true undecided coding system, which trashes + ;; non-Latin-1 on writing). It might just be the value of + ;; coding-system passed to #'insert-file-contents-internal. + (setq coding-system used-codesys) + ;; Otherwise, take the value normally specified by the + ;; language environment: + (setq coding-system (default-value 'buffer-file-coding-system)))) ;; call any `post-read-conversion' for the coding system that ;; was used ... (let ((func