Mercurial > hg > xemacs-beta
changeset 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 | 3972966a4588 |
children | 25e5e5346d31 |
files | lisp/ChangeLog lisp/code-files.el tests/ChangeLog tests/automated/mule-tests.el |
diffstat | 4 files changed, 57 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Sun Jul 12 14:20:55 2009 +0100 +++ b/lisp/ChangeLog Mon Jul 13 20:45:26 2009 +0100 @@ -1,3 +1,12 @@ +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. + 2009-07-12 Aidan Kehoe <kehoea@parhasard.net> * files.el (after-find-file):
--- 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
--- a/tests/ChangeLog Sun Jul 12 14:20:55 2009 +0100 +++ b/tests/ChangeLog Mon Jul 13 20:45:26 2009 +0100 @@ -1,3 +1,10 @@ +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. + 2009-07-11 Aidan Kehoe <kehoea@parhasard.net> * automated/mule-tests.el:
--- a/tests/automated/mule-tests.el Sun Jul 12 14:20:55 2009 +0100 +++ b/tests/automated/mule-tests.el Mon Jul 13 20:45:26 2009 +0100 @@ -158,6 +158,7 @@ (find-file nonexistent-file-name coding-system) (Assert (eq (find-coding-system coding-system) buffer-file-coding-system)) + (set-buffer-modified-p nil) (kill-buffer nil))) (delete-file existing-file-name))