comparison lisp/files.el @ 47089:37900cd8903a

(make-auto-save-file-name, make-backup-file-name-1): Don't use directory-sep-char.
author Richard M. Stallman <rms@gnu.org>
date Wed, 28 Aug 2002 22:16:42 +0000
parents a2c9058db731
children 9c336e422221
comparison
equal deleted inserted replaced
47088:d4f9e484db41 47089:37900cd8903a
2572 (concat (make-backup-file-name-1 file) "~")))) 2572 (concat (make-backup-file-name-1 file) "~"))))
2573 2573
2574 (defun make-backup-file-name-1 (file) 2574 (defun make-backup-file-name-1 (file)
2575 "Subroutine of `make-backup-file-name' and `find-backup-file-name'." 2575 "Subroutine of `make-backup-file-name' and `find-backup-file-name'."
2576 (let ((alist backup-directory-alist) 2576 (let ((alist backup-directory-alist)
2577 elt backup-directory dir-sep-string) 2577 elt backup-directory)
2578 (while alist 2578 (while alist
2579 (setq elt (pop alist)) 2579 (setq elt (pop alist))
2580 (if (string-match (car elt) file) 2580 (if (string-match (car elt) file)
2581 (setq backup-directory (cdr elt) 2581 (setq backup-directory (cdr elt)
2582 alist nil))) 2582 alist nil)))
2587 (make-directory backup-directory 'parents) 2587 (make-directory backup-directory 'parents)
2588 (file-error file))) 2588 (file-error file)))
2589 (if (file-name-absolute-p backup-directory) 2589 (if (file-name-absolute-p backup-directory)
2590 (progn 2590 (progn
2591 (when (memq system-type '(windows-nt ms-dos)) 2591 (when (memq system-type '(windows-nt ms-dos))
2592 ;; Normalize DOSish file names: convert all slashes to 2592 ;; Normalize DOSish file names: downcase the drive
2593 ;; directory-sep-char, downcase the drive letter, if any, 2593 ;; letter, if any, and replace the leading "x:" with
2594 ;; and replace the leading "x:" with "/drive_x". 2594 ;; "/drive_x".
2595 (or (file-name-absolute-p file) 2595 (or (file-name-absolute-p file)
2596 (setq file (expand-file-name file))) ; make defaults explicit 2596 (setq file (expand-file-name file))) ; make defaults explicit
2597 ;; Replace any invalid file-name characters (for the 2597 ;; Replace any invalid file-name characters (for the
2598 ;; case of backing up remote files). 2598 ;; case of backing up remote files).
2599 (setq file (expand-file-name (convert-standard-filename file))) 2599 (setq file (expand-file-name (convert-standard-filename file)))
2600 (setq dir-sep-string (char-to-string directory-sep-char))
2601 (if (eq (aref file 1) ?:) 2600 (if (eq (aref file 1) ?:)
2602 (setq file (concat dir-sep-string 2601 (setq file (concat "/"
2603 "drive_" 2602 "drive_"
2604 (char-to-string (downcase (aref file 0))) 2603 (char-to-string (downcase (aref file 0)))
2605 (if (eq (aref file 2) directory-sep-char) 2604 (if (eq (aref file 2) ?/)
2606 "" 2605 ""
2607 dir-sep-string) 2606 "/")
2608 (substring file 2))))) 2607 (substring file 2)))))
2609 ;; Make the name unique by substituting directory 2608 ;; Make the name unique by substituting directory
2610 ;; separators. It may not really be worth bothering about 2609 ;; separators. It may not really be worth bothering about
2611 ;; doubling `!'s in the original name... 2610 ;; doubling `!'s in the original name...
2612 (expand-file-name 2611 (expand-file-name
2613 (subst-char-in-string 2612 (subst-char-in-string
2614 directory-sep-char ?! 2613 ?/ ?!
2615 (replace-regexp-in-string "!" "!!" file)) 2614 (replace-regexp-in-string "!" "!!" file))
2616 backup-directory)) 2615 backup-directory))
2617 (expand-file-name (file-name-nondirectory file) 2616 (expand-file-name (file-name-nondirectory file)
2618 (file-name-as-directory 2617 (file-name-as-directory
2619 (expand-file-name backup-directory 2618 (expand-file-name backup-directory
3561 (if result 3560 (if result
3562 (if uniq 3561 (if uniq
3563 (setq filename (concat 3562 (setq filename (concat
3564 (file-name-directory result) 3563 (file-name-directory result)
3565 (subst-char-in-string 3564 (subst-char-in-string
3566 directory-sep-char ?! 3565 ?/ ?!
3567 (replace-regexp-in-string "!" "!!" 3566 (replace-regexp-in-string "!" "!!"
3568 filename)))) 3567 filename))))
3569 (setq filename result))) 3568 (setq filename result)))
3570 (setq result 3569 (setq result
3571 (if (and (eq system-type 'ms-dos) 3570 (if (and (eq system-type 'ms-dos)