comparison lisp/dos-w32.el @ 72052:d317c5ea9079

(find-buffer-file-type-coding-system): Support calls where `(nth 1 command)' is a cons cell. Doc fix.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 21 Jul 2006 09:20:02 +0000
parents 4dc3f74ad23f
children ddcbd2c1b70d 858cb33ae39d
comparison
equal deleted inserted replaced
72051:99418e03cb74 72052:d317c5ea9079
86 (funcall code filename)))))) 86 (funcall code filename))))))
87 87
88 (setq-default buffer-file-coding-system 'undecided-dos) 88 (setq-default buffer-file-coding-system 'undecided-dos)
89 89
90 (defun find-buffer-file-type-coding-system (command) 90 (defun find-buffer-file-type-coding-system (command)
91 "Choose a coding system for a file operation. 91 "Choose a coding system for a file operation in COMMAND.
92 If COMMAND is `insert-file-contents', the coding system is chosen based 92 COMMAND is a list that specifies the operation, and I/O primitive as its
93 upon the filename, the contents of `untranslated-filesystem-list' and 93 CAR, and the arguments that might be given to that operation as its CDR.
94 `file-name-buffer-file-type-alist', and whether the file exists: 94 If operation is `insert-file-contents', the coding system is chosen based
95 upon the filename (the CAR of the arguments beyond the operation), the contents
96 of `untranslated-filesystem-list' and `file-name-buffer-file-type-alist',
97 and whether the file exists:
95 98
96 If it matches in `untranslated-filesystem-list': 99 If it matches in `untranslated-filesystem-list':
97 If the file exists: `undecided' 100 If the file exists: `undecided'
98 If the file does not exist: `undecided-unix' 101 If the file does not exist: `undecided-unix'
99 If it matches in `file-name-buffer-file-type-alist': 102 If it matches in `file-name-buffer-file-type-alist':
101 If the match is nil (for dos-text): `undecided-dos' 104 If the match is nil (for dos-text): `undecided-dos'
102 Otherwise: 105 Otherwise:
103 If the file exists: `undecided' 106 If the file exists: `undecided'
104 If the file does not exist: default-buffer-file-coding-system 107 If the file does not exist: default-buffer-file-coding-system
105 108
106 If COMMAND is `write-region', the coding system is chosen based upon 109 If operation is `write-region', the coding system is chosen based upon
107 the value of `buffer-file-coding-system' and `buffer-file-type'. If 110 the value of `buffer-file-coding-system' and `buffer-file-type'. If
108 `buffer-file-coding-system' is non-nil, its value is used. If it is 111 `buffer-file-coding-system' is non-nil, its value is used. If it is
109 nil and `buffer-file-type' is t, the coding system is `no-conversion'. 112 nil and `buffer-file-type' is t, the coding system is `no-conversion'.
110 Otherwise, it is `undecided-dos'. 113 Otherwise, it is `undecided-dos'.
111 114
124 (target) 127 (target)
125 (binary nil) (text nil) 128 (binary nil) (text nil)
126 (undecided nil) (undecided-unix nil)) 129 (undecided nil) (undecided-unix nil))
127 (cond ((eq op 'insert-file-contents) 130 (cond ((eq op 'insert-file-contents)
128 (setq target (nth 1 command)) 131 (setq target (nth 1 command))
132 ;; If TARGET is a cons cell, it has the form (FILENAME . BUFFER),
133 ;; where BUFFER is a buffer into which the file was already read,
134 ;; but its contents were not yet decoded. (This form of the
135 ;; arguments is used, e.g., in arc-mode.el.) This function
136 ;; doesn't care about the contents, it only looks at the file's
137 ;; name, which is the CAR of the cons cell.
138 (if (consp target) (setq target (car target)))
129 ;; First check for a file name that indicates 139 ;; First check for a file name that indicates
130 ;; it is truly binary. 140 ;; it is truly binary.
131 (setq binary (find-buffer-file-type target)) 141 (setq binary (find-buffer-file-type target))
132 (cond (binary) 142 (cond (binary)
133 ;; Next check for files that MUST use DOS eol conversion. 143 ;; Next check for files that MUST use DOS eol conversion.