diff options
| author | Eli Zaretskii | 2017-12-01 12:40:26 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2017-12-01 12:40:26 +0200 |
| commit | 8c8b6732882248df4ca3b687e0a4b4e5e4ab3777 (patch) | |
| tree | f2ecf904572d9814062f66416abada866f150a43 | |
| parent | 8eb6870be690128fb1cbc012c55093813c39830c (diff) | |
| download | emacs-8c8b6732882248df4ca3b687e0a4b4e5e4ab3777.tar.gz emacs-8c8b6732882248df4ca3b687e0a4b4e5e4ab3777.zip | |
Fix backing up remote files in local directories on MS-Windows
* lisp/files.el (make-backup-file-name-1): Support remote file
names correctly when they are backed up into a local directory on
MS-Windows and MS-DOS. (Bug#29440)
| -rw-r--r-- | lisp/files.el | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/lisp/files.el b/lisp/files.el index 8021e1bbed5..9a79b2a0c73 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4653,25 +4653,41 @@ The function `find-backup-file-name' also uses this." | |||
| 4653 | ;; "/drive_x". | 4653 | ;; "/drive_x". |
| 4654 | (or (file-name-absolute-p file) | 4654 | (or (file-name-absolute-p file) |
| 4655 | (setq file (expand-file-name file))) ; make defaults explicit | 4655 | (setq file (expand-file-name file))) ; make defaults explicit |
| 4656 | ;; Replace any invalid file-name characters (for the | 4656 | (cond |
| 4657 | ;; case of backing up remote files). | 4657 | ((file-remote-p file) |
| 4658 | (setq file (expand-file-name (convert-standard-filename file))) | 4658 | ;; Remove the leading slash, if any, to prevent |
| 4659 | (if (eq (aref file 1) ?:) | 4659 | ;; expand-file-name from adding a drive letter. |
| 4660 | (setq file (concat "/" | 4660 | (and (memq (aref file 0) '(?/ ?\\)) |
| 4661 | "drive_" | 4661 | (setq file (substring file 1))) |
| 4662 | (char-to-string (downcase (aref file 0))) | 4662 | ;; Replace any invalid file-name characters. |
| 4663 | (if (eq (aref file 2) ?/) | 4663 | (setq file (convert-standard-filename file)) |
| 4664 | "" | 4664 | ;; Replace slashes to make the file name unique, and |
| 4665 | "/") | 4665 | ;; prepend backup-directory. |
| 4666 | (substring file 2))))) | 4666 | (expand-file-name |
| 4667 | ;; Make the name unique by substituting directory | 4667 | (subst-char-in-string |
| 4668 | ;; separators. It may not really be worth bothering about | 4668 | ?/ ?! |
| 4669 | ;; doubling `!'s in the original name... | 4669 | (replace-regexp-in-string "!" "!!" |
| 4670 | (expand-file-name | 4670 | (concat "/" file))) |
| 4671 | (subst-char-in-string | 4671 | backup-directory)) |
| 4672 | ?/ ?! | 4672 | (t |
| 4673 | (replace-regexp-in-string "!" "!!" file)) | 4673 | ;; Replace any invalid file-name characters. |
| 4674 | backup-directory)) | 4674 | (setq file (expand-file-name (convert-standard-filename file))) |
| 4675 | (if (eq (aref file 1) ?:) | ||
| 4676 | (setq file (concat "/" | ||
| 4677 | "drive_" | ||
| 4678 | (char-to-string (downcase (aref file 0))) | ||
| 4679 | (if (eq (aref file 2) ?/) | ||
| 4680 | "" | ||
| 4681 | "/") | ||
| 4682 | (substring file 2)))) | ||
| 4683 | ;; Make the name unique by substituting directory | ||
| 4684 | ;; separators. It may not really be worth bothering about | ||
| 4685 | ;; doubling `!'s in the original name... | ||
| 4686 | (expand-file-name | ||
| 4687 | (subst-char-in-string | ||
| 4688 | ?/ ?! | ||
| 4689 | (replace-regexp-in-string "!" "!!" file)) | ||
| 4690 | backup-directory))))) | ||
| 4675 | (expand-file-name (file-name-nondirectory file) | 4691 | (expand-file-name (file-name-nondirectory file) |
| 4676 | (file-name-as-directory abs-backup-directory)))))) | 4692 | (file-name-as-directory abs-backup-directory)))))) |
| 4677 | 4693 | ||