Mercurial > emacs
changeset 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 | a09997b3243a |
children | c070f80d6e4c |
files | lisp/dos-w32.el |
diffstat | 1 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/dos-w32.el Sat Jan 17 10:20:48 2009 +0000 +++ b/lisp/dos-w32.el Sat Jan 17 12:34:09 2009 +0000 @@ -129,9 +129,9 @@ `buffer-file-coding-system' will be used when writing the file." (let ((op (nth 0 command)) - (target) (binary nil) (text nil) - (undecided nil) (undecided-unix nil)) + (undecided nil) (undecided-unix nil) + target target-buf) (cond ((eq op 'insert-file-contents) (setq target (nth 1 command)) ;; If TARGET is a cons cell, it has the form (FILENAME . BUFFER), @@ -140,7 +140,11 @@ ;; arguments is used, e.g., in arc-mode.el.) This function ;; doesn't care about the contents, it only looks at the file's ;; name, which is the CAR of the cons cell. - (if (consp target) (setq target (car target))) + (when (consp target) + (setq target-buf + (and (bufferp (cdr target)) + (buffer-name (cdr target)))) + (setq target (car target))) ;; First check for a file name that indicates ;; it is truly binary. (setq binary (find-buffer-file-type target)) @@ -149,7 +153,17 @@ ((find-buffer-file-type-match target) (setq text t)) ;; For any other existing file, decide based on contents. - ((file-exists-p target) + ((or + (file-exists-p target) + ;; If TARGET does not exist as a file, replace its + ;; base name with TARGET-BUF and try again. This + ;; is for jka-compr's sake, which strips the + ;; compression (.gz etc.) extension from the + ;; FILENAME, but leaves it in the BUFFER's name. + (and (stringp target-buf) + (file-exists-p + (expand-file-name target-buf + (file-name-directory target))))) (setq undecided t)) ;; Next check for a non-DOS file system. ((untranslated-file-p target)