Mercurial > emacs
comparison lisp/dos-w32.el @ 101245:5b95a230db1f
(find-buffer-file-type-coding-system): If `(car target)' does not exist as a
file, try again with its basename replaced by `(cdr target)'. Fixes Bug #1853.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 17 Jan 2009 12:34:09 +0000 |
parents | a9dc0e7c3f2b |
children | 790bd85e4cb0 |
comparison
equal
deleted
inserted
replaced
101244:a09997b3243a | 101245:5b95a230db1f |
---|---|
127 LFs are detected. In both cases, `buffer-file-coding-system' will be | 127 LFs are detected. In both cases, `buffer-file-coding-system' will be |
128 set to the appropriate coding system, and the value of | 128 set to the appropriate coding system, and the value of |
129 `buffer-file-coding-system' will be used when writing the file." | 129 `buffer-file-coding-system' will be used when writing the file." |
130 | 130 |
131 (let ((op (nth 0 command)) | 131 (let ((op (nth 0 command)) |
132 (target) | |
133 (binary nil) (text nil) | 132 (binary nil) (text nil) |
134 (undecided nil) (undecided-unix nil)) | 133 (undecided nil) (undecided-unix nil) |
134 target target-buf) | |
135 (cond ((eq op 'insert-file-contents) | 135 (cond ((eq op 'insert-file-contents) |
136 (setq target (nth 1 command)) | 136 (setq target (nth 1 command)) |
137 ;; If TARGET is a cons cell, it has the form (FILENAME . BUFFER), | 137 ;; If TARGET is a cons cell, it has the form (FILENAME . BUFFER), |
138 ;; where BUFFER is a buffer into which the file was already read, | 138 ;; where BUFFER is a buffer into which the file was already read, |
139 ;; but its contents were not yet decoded. (This form of the | 139 ;; but its contents were not yet decoded. (This form of the |
140 ;; arguments is used, e.g., in arc-mode.el.) This function | 140 ;; arguments is used, e.g., in arc-mode.el.) This function |
141 ;; doesn't care about the contents, it only looks at the file's | 141 ;; doesn't care about the contents, it only looks at the file's |
142 ;; name, which is the CAR of the cons cell. | 142 ;; name, which is the CAR of the cons cell. |
143 (if (consp target) (setq target (car target))) | 143 (when (consp target) |
144 (setq target-buf | |
145 (and (bufferp (cdr target)) | |
146 (buffer-name (cdr target)))) | |
147 (setq target (car target))) | |
144 ;; First check for a file name that indicates | 148 ;; First check for a file name that indicates |
145 ;; it is truly binary. | 149 ;; it is truly binary. |
146 (setq binary (find-buffer-file-type target)) | 150 (setq binary (find-buffer-file-type target)) |
147 (cond (binary) | 151 (cond (binary) |
148 ;; Next check for files that MUST use DOS eol conversion. | 152 ;; Next check for files that MUST use DOS eol conversion. |
149 ((find-buffer-file-type-match target) | 153 ((find-buffer-file-type-match target) |
150 (setq text t)) | 154 (setq text t)) |
151 ;; For any other existing file, decide based on contents. | 155 ;; For any other existing file, decide based on contents. |
152 ((file-exists-p target) | 156 ((or |
157 (file-exists-p target) | |
158 ;; If TARGET does not exist as a file, replace its | |
159 ;; base name with TARGET-BUF and try again. This | |
160 ;; is for jka-compr's sake, which strips the | |
161 ;; compression (.gz etc.) extension from the | |
162 ;; FILENAME, but leaves it in the BUFFER's name. | |
163 (and (stringp target-buf) | |
164 (file-exists-p | |
165 (expand-file-name target-buf | |
166 (file-name-directory target))))) | |
153 (setq undecided t)) | 167 (setq undecided t)) |
154 ;; Next check for a non-DOS file system. | 168 ;; Next check for a non-DOS file system. |
155 ((untranslated-file-p target) | 169 ((untranslated-file-p target) |
156 (setq undecided-unix t))) | 170 (setq undecided-unix t))) |
157 (cond (binary '(no-conversion . no-conversion)) | 171 (cond (binary '(no-conversion . no-conversion)) |