emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp dos-w32.el


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs/lisp dos-w32.el
Date: Sat, 17 Jan 2009 12:34:09 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Eli Zaretskii <eliz>    09/01/17 12:34:09

Modified files:
        lisp           : dos-w32.el 

Log message:
        (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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/dos-w32.el?cvsroot=emacs&r1=1.56&r2=1.57

Patches:
Index: dos-w32.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/dos-w32.el,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- dos-w32.el  5 Jan 2009 03:18:56 -0000       1.56
+++ dos-w32.el  17 Jan 2009 12:34:09 -0000      1.57
@@ -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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]