comparison lisp/code-files.el @ 4641:a90b63846dc4

Set buffer-file-coding-system more sensibly with zero-length files. lisp/ChangeLog addition: 2009-06-07 Aidan Kehoe <kehoea@parhasard.net> * code-files.el (insert-file-contents): Autodetection may return undecided as a coding system. If the file was zero-length, this is kosher, and we should set buffer-file-coding-system to its default; if it is not zero-length, we still need to set b-f-c-s, but we warn that the autodetection fails. (Ignoring that for the user, autodetection failing is something very distinct from what we use it to mean here.) See http://mid.gmane.org/18986.53111.800393.660612@parhasard.net and the related thread.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 07 Jun 2009 16:47:04 +0100
parents 7a8c613ee283
children e4ed58cb0e5b
comparison
equal deleted inserted replaced
4640:8cef85a39d2c 4641:a90b63846dc4
441 (file-error 441 (file-error
442 (run-hook-with-args 'insert-file-contents-error-hook 442 (run-hook-with-args 'insert-file-contents-error-hook
443 filename visit err) 443 filename visit err)
444 (signal (car err) (cdr err)))) 444 (signal (car err) (cdr err))))
445 (setq coding-system used-codesys) 445 (setq coding-system used-codesys)
446 ;; If the file was zero-length, used-codesys is undecided. Set it to
447 ;; a more sane value.
448 (when (eq 'undecided (coding-system-type coding-system))
449 (unless (zerop (buffer-size))
450 (warn "%s: autodetection failed: setting to default."
451 (file-name-nondirectory (buffer-file-name))))
452 (setq coding-system (default-value 'buffer-file-coding-system)))
446 ;; call any `post-read-conversion' for the coding system that 453 ;; call any `post-read-conversion' for the coding system that
447 ;; was used ... 454 ;; was used ...
448 (let ((func 455 (let ((func
449 (coding-system-property coding-system 'post-read-conversion)) 456 (coding-system-property coding-system 'post-read-conversion))
450 (endmark (make-marker))) 457 (endmark (make-marker)))