Mercurial > emacs
comparison lisp/dos-w32.el @ 18872:8c7bcffd7327
(find-buffer-file-type-coding-system):
Use undecided-dos for dos-text file names.
Use undecided for non-existing untranslated file names.
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Sun, 20 Jul 1997 01:30:54 +0000 |
parents | 62090ffa4583 |
children | d6d9a466fad2 |
comparison
equal
deleted
inserted
replaced
18871:32c4a961d11f | 18872:8c7bcffd7327 |
---|---|
26 | 26 |
27 ;; Parts of this code are duplicated functions taken from dos-fns.el | 27 ;; Parts of this code are duplicated functions taken from dos-fns.el |
28 ;; and winnt.el. | 28 ;; and winnt.el. |
29 | 29 |
30 ;;; Code: | 30 ;;; Code: |
31 | |
32 ;;; Add %t: into the mode line format just after the open-paren. | |
33 (let ((tail (member " %[(" mode-line-format))) | |
34 (setcdr tail (cons (purecopy "%t:") | |
35 (cdr tail)))) | |
36 | 31 |
37 ;; Use ";" instead of ":" as a path separator (from files.el). | 32 ;; Use ";" instead of ":" as a path separator (from files.el). |
38 (setq path-separator ";") | 33 (setq path-separator ";") |
39 | 34 |
40 ;; Set the null device (for compile.el). | 35 ;; Set the null device (for compile.el). |
90 ((and (symbolp code) (fboundp code)) | 85 ((and (symbolp code) (fboundp code)) |
91 (funcall code filename))))))) | 86 (funcall code filename))))))) |
92 | 87 |
93 (defun find-buffer-file-type-coding-system (command args) | 88 (defun find-buffer-file-type-coding-system (command args) |
94 "Choose a coding system for a file operation. | 89 "Choose a coding system for a file operation. |
95 If COMMAND is 'insert-file-contents', the coding system is chosen based | 90 If COMMAND is `insert-file-contents', the coding system is chosen based |
96 upon the filename, the contents of 'untranslated-filesystem-list' and | 91 upon the filename, the contents of `untranslated-filesystem-list' and |
97 'file-name-buffer-file-type-alist', and whether the file exists: | 92 `file-name-buffer-file-type-alist', and whether the file exists: |
98 | 93 |
99 If it matches in 'untranslated-filesystem-list': 'no-conversion' | 94 If it matches in `untranslated-filesystem-list': |
100 If it matches in 'file-name-buffer-file-type-alist': | 95 If the file exists: `no-conversion' |
101 If the match is t (for binary): 'no-conversion' | 96 If the file does not exist: `undecided' |
102 If the match is nil (for text): 'emacs-mule-dos' | 97 If it matches in `file-name-buffer-file-type-alist': |
98 If the match is t (for binary): `no-conversion' | |
99 If the match is nil (for dos-text): `undecided-dos' | |
103 Otherwise: | 100 Otherwise: |
104 If the file exists: 'undecided' | 101 If the file exists: `undecided' |
105 If the file does not exist: 'undecided-dos' | 102 If the file does not exist: `undecided-dos' |
106 | 103 |
107 If COMMAND is 'write-region', the coding system is chosen based | 104 If COMMAND is `write-region', the coding system is chosen based |
108 upon the value of 'buffer-file-type': If t, the coding system is | 105 upon the value of `buffer-file-type': If t, the coding system is |
109 'no-conversion', otherwise it is 'emacs-mule-dos'." | 106 `no-conversion', otherwise it is `undecided-dos'." |
110 (let ((op (nth 0 command)) | 107 (let ((op (nth 0 command)) |
111 (target) | 108 (target) |
112 (binary nil) (text nil) | 109 (binary nil) (text nil) |
113 (undecided nil)) | 110 (undecided nil)) |
114 (cond ((eq op 'insert-file-contents) | 111 (cond ((eq op 'insert-file-contents) |
115 (setq target (nth 1 command)) | 112 (setq target (nth 1 command)) |
116 (setq binary (find-buffer-file-type target)) | 113 (if (untranslated-file-p target) |
117 (unless binary | 114 (if (file-exists-p target) |
118 (if (find-buffer-file-type-match target) | 115 (setq undecided t) |
119 (setq text t) | 116 (setq binary t)) |
120 (setq undecided (file-exists-p target))))) | 117 (setq binary (find-buffer-file-type target)) |
118 (unless binary | |
119 (if (find-buffer-file-type-match target) | |
120 (setq text t) | |
121 (setq undecided (file-exists-p target)))))) | |
121 ((eq op 'write-region) | 122 ((eq op 'write-region) |
122 (setq binary buffer-file-type))) | 123 (setq binary buffer-file-type))) |
123 (cond (binary '(no-conversion . no-conversion)) | 124 (cond (binary '(no-conversion . no-conversion)) |
124 (text '(emacs-mule-dos . emacs-mule-dos)) | 125 (text '(undecided-dos . undecided-dos)) |
125 (undecided '(undecided . undecided)) | 126 (undecided '(undecided . undecided)) |
126 (t '(undecided-dos . undecided-dos))))) | 127 (t '(undecided-dos . undecided-dos))))) |
127 | 128 |
128 (modify-coding-system-alist 'file "" 'find-buffer-file-type-coding-system) | 129 (modify-coding-system-alist 'file "" 'find-buffer-file-type-coding-system) |
129 | 130 |
212 ;; Process I/O decoding and encoding. | 213 ;; Process I/O decoding and encoding. |
213 | 214 |
214 (defun find-binary-process-coding-system (op args) | 215 (defun find-binary-process-coding-system (op args) |
215 "Choose a coding system for process I/O. | 216 "Choose a coding system for process I/O. |
216 The coding system for decode is 'no-conversion' if 'binary-process-output' | 217 The coding system for decode is 'no-conversion' if 'binary-process-output' |
217 is non-nil, and 'emacs-mule-dos' otherwise. Similarly, the coding system | 218 is non-nil, and 'undecided-dos' otherwise. Similarly, the coding system |
218 for encode is 'no-conversion' if 'binary-process-input' is non-nil, | 219 for encode is 'no-conversion' if 'binary-process-input' is non-nil, |
219 and 'emacs-mule-dos' otherwise." | 220 and 'undecided-dos' otherwise." |
220 (let ((decode 'emacs-mule-dos) | 221 (let ((decode 'undecided-dos) |
221 (encode 'emacs-mule-dos)) | 222 (encode 'undecided-dos)) |
222 (if binary-process-output | 223 (if binary-process-output |
223 (setq decode 'no-conversion)) | 224 (setq decode 'no-conversion)) |
224 (if binary-process-input | 225 (if binary-process-input |
225 (setq encode 'no-conversion)) | 226 (setq encode 'no-conversion)) |
226 (cons decode encode))) | 227 (cons decode encode))) |