aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-09-01 17:04:41 +0000
committerRichard M. Stallman1997-09-01 17:04:41 +0000
commit73b2c6642378286fcfaf0aff5096e36c192e87c8 (patch)
tree63491f9eddbe29b278399a823b1f1f64ae8515a7
parent094550e6868359f20f7633fb543574b536e2772d (diff)
downloademacs-73b2c6642378286fcfaf0aff5096e36c192e87c8.tar.gz
emacs-73b2c6642378286fcfaf0aff5096e36c192e87c8.zip
(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.
-rw-r--r--lisp/dos-w32.el48
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.")
72 (setq alist (cdr alist))) 72 (setq alist (cdr alist)))
73 found))) 73 found)))
74 74
75;; Don't check for untranslated file systems here.
75(defun find-buffer-file-type (filename) 76(defun find-buffer-file-type (filename)
76 ;; First check if file is on an untranslated filesystem, then on the alist. 77 (let ((match (find-buffer-file-type-match filename))
77 (if (untranslated-file-p filename) 78 (code))
78 t ; for binary 79 (if (not match)
79 (let ((match (find-buffer-file-type-match filename)) 80 default-buffer-file-type
80 (code)) 81 (setq code (cdr match))
81 (if (not match) 82 (cond ((memq code '(nil t)) code)
82 default-buffer-file-type 83 ((and (symbolp code) (fboundp code))
83 (setq code (cdr match)) 84 (funcall code filename))))))
84 (cond ((memq code '(nil t)) code)
85 ((and (symbolp code) (fboundp code))
86 (funcall code filename)))))))
87 85
88(setq-default buffer-file-coding-system 'undecided-dos) 86(setq-default buffer-file-coding-system 'undecided-dos)
89 87
@@ -123,26 +121,34 @@ set to the appropriate coding system, and the value of
123 (let ((op (nth 0 command)) 121 (let ((op (nth 0 command))
124 (target) 122 (target)
125 (binary nil) (text nil) 123 (binary nil) (text nil)
126 (undecided nil)) 124 (undecided nil) (undecided-unix nil))
127 (cond ((eq op 'insert-file-contents) 125 (cond ((eq op 'insert-file-contents)
128 (setq target (nth 1 command)) 126 (setq target (nth 1 command))
129 (if (untranslated-file-p target) 127 ;; First check for a file name that indicates
130 (if (file-exists-p target) 128 ;; it is truly binary.
131 (setq undecided t) 129 (setq binary (find-buffer-file-type target))
132 (setq binary t)) 130 (cond (binary)
133 (setq binary (find-buffer-file-type target)) 131 ;; Next check for files that MUST use DOS eol conversion.
134 (unless binary 132 ((find-buffer-file-type-match target)
135 (if (find-buffer-file-type-match target) 133 (setq text t))
136 (setq text t) 134 ;; For any other existing file, decide based on contents.
137 (setq undecided (file-exists-p target))))) 135 ((file-exists-p target)
136 (setq undecided t))
137 ;; Next check for a non-DOS file system.
138 ((untranslated-file-p target)
139 (setq undecided-unix t)))
138 (cond (binary '(no-conversion . no-conversion)) 140 (cond (binary '(no-conversion . no-conversion))
139 (text '(undecided-dos . undecided-dos)) 141 (text '(undecided-dos . undecided-dos))
142 (undecided-unix '(undecided-unix . undecided-unix))
140 (undecided '(undecided . undecided)) 143 (undecided '(undecided . undecided))
141 (t '(undecided-dos . undecided-dos)))) 144 (t '(undecided-dos . undecided-dos))))
142 ((eq op 'write-region) 145 ((eq op 'write-region)
143 (if buffer-file-coding-system 146 (if buffer-file-coding-system
144 (cons buffer-file-coding-system 147 (cons buffer-file-coding-system
145 buffer-file-coding-system) 148 buffer-file-coding-system)
149 ;; Normally this is used only in a non-file-visiting
150 ;; buffer, because normally buffer-file-coding-system is non-nil
151 ;; in a file-visiting buffer.
146 (if buffer-file-type 152 (if buffer-file-type
147 '(no-conversion . no-conversion) 153 '(no-conversion . no-conversion)
148 '(undecided-dos . undecided-dos))))))) 154 '(undecided-dos . undecided-dos)))))))