diff options
author | Richard M. Stallman <rms@gnu.org> | 1997-09-01 17:04:41 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1997-09-01 17:04:41 +0000 |
commit | 73b2c6642378286fcfaf0aff5096e36c192e87c8 (patch) | |
tree | 63491f9eddbe29b278399a823b1f1f64ae8515a7 /lisp/dos-w32.el | |
parent | 094550e6868359f20f7633fb543574b536e2772d (diff) | |
download | emacs-73b2c6642378286fcfaf0aff5096e36c192e87c8.tar.gz |
(find-buffer-file-type): Don't check for untranslated file systems here.
(find-buffer-file-type-coding-system): For reading a file,
check for binary file, then text file, then existing file,
then whether file name is translated.
Diffstat (limited to 'lisp/dos-w32.el')
-rw-r--r-- | lisp/dos-w32.el | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/lisp/dos-w32.el b/lisp/dos-w32.el index bf7d5447fd7..71db8f9513b 100644 --- a/lisp/dos-w32.el +++ b/lisp/dos-w32.el @@ -72,18 +72,16 @@ against the file name, and TYPE is nil for text, t for binary.") (setq alist (cdr alist))) found))) +;; Don't check for untranslated file systems here. (defun find-buffer-file-type (filename) - ;; First check if file is on an untranslated filesystem, then on the alist. - (if (untranslated-file-p filename) - t ; for binary - (let ((match (find-buffer-file-type-match filename)) - (code)) - (if (not match) - default-buffer-file-type - (setq code (cdr match)) - (cond ((memq code '(nil t)) code) - ((and (symbolp code) (fboundp code)) - (funcall code filename))))))) + (let ((match (find-buffer-file-type-match filename)) + (code)) + (if (not match) + default-buffer-file-type + (setq code (cdr match)) + (cond ((memq code '(nil t)) code) + ((and (symbolp code) (fboundp code)) + (funcall code filename)))))) (setq-default buffer-file-coding-system 'undecided-dos) @@ -123,26 +121,34 @@ set to the appropriate coding system, and the value of (let ((op (nth 0 command)) (target) (binary nil) (text nil) - (undecided nil)) + (undecided nil) (undecided-unix nil)) (cond ((eq op 'insert-file-contents) (setq target (nth 1 command)) - (if (untranslated-file-p target) - (if (file-exists-p target) - (setq undecided t) - (setq binary t)) - (setq binary (find-buffer-file-type target)) - (unless binary - (if (find-buffer-file-type-match target) - (setq text t) - (setq undecided (file-exists-p target))))) + ;; First check for a file name that indicates + ;; it is truly binary. + (setq binary (find-buffer-file-type target)) + (cond (binary) + ;; Next check for files that MUST use DOS eol conversion. + ((find-buffer-file-type-match target) + (setq text t)) + ;; For any other existing file, decide based on contents. + ((file-exists-p target) + (setq undecided t)) + ;; Next check for a non-DOS file system. + ((untranslated-file-p target) + (setq undecided-unix t))) (cond (binary '(no-conversion . no-conversion)) (text '(undecided-dos . undecided-dos)) + (undecided-unix '(undecided-unix . undecided-unix)) (undecided '(undecided . undecided)) (t '(undecided-dos . undecided-dos)))) ((eq op 'write-region) (if buffer-file-coding-system (cons buffer-file-coding-system buffer-file-coding-system) + ;; Normally this is used only in a non-file-visiting + ;; buffer, because normally buffer-file-coding-system is non-nil + ;; in a file-visiting buffer. (if buffer-file-type '(no-conversion . no-conversion) '(undecided-dos . undecided-dos))))))) |