diff options
| author | Eli Zaretskii | 2017-12-02 10:57:15 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2017-12-02 10:57:15 +0200 |
| commit | 66ec92af0060952ef7b53a8f1c07177cf38b3145 (patch) | |
| tree | b8b1fc6609e40f5fe6698db341b0ff9861bfcd0c | |
| parent | 7e61e74da7ee3fe5eaa5ca76d23be84831c394c9 (diff) | |
| download | emacs-66ec92af0060952ef7b53a8f1c07177cf38b3145.tar.gz emacs-66ec92af0060952ef7b53a8f1c07177cf38b3145.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 | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/lisp/files.el b/lisp/files.el index 8021e1bbed5..1bdb6d38ab9 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4653,25 +4653,35 @@ 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 | ;; convert-standard-filename from converting that to a |
| 4660 | (setq file (concat "/" | 4660 | ;; backslash. |
| 4661 | "drive_" | 4661 | (and (memq (aref file 0) '(?/ ?\\)) |
| 4662 | (char-to-string (downcase (aref file 0))) | 4662 | (setq file (substring file 1))) |
| 4663 | (if (eq (aref file 2) ?/) | 4663 | ;; Replace any invalid file-name characters, then |
| 4664 | "" | 4664 | ;; prepend the leading slash back. |
| 4665 | "/") | 4665 | (setq file (concat "/" (convert-standard-filename file)))) |
| 4666 | (substring file 2))))) | 4666 | (t |
| 4667 | ;; Make the name unique by substituting directory | 4667 | ;; Replace any invalid file-name characters. |
| 4668 | ;; separators. It may not really be worth bothering about | 4668 | (setq file (expand-file-name (convert-standard-filename file))) |
| 4669 | ;; doubling `!'s in the original name... | 4669 | (if (eq (aref file 1) ?:) |
| 4670 | (expand-file-name | 4670 | (setq file (concat "/" |
| 4671 | (subst-char-in-string | 4671 | "drive_" |
| 4672 | ?/ ?! | 4672 | (char-to-string (downcase (aref file 0))) |
| 4673 | (replace-regexp-in-string "!" "!!" file)) | 4673 | (if (eq (aref file 2) ?/) |
| 4674 | backup-directory)) | 4674 | "" |
| 4675 | "/") | ||
| 4676 | (substring file 2)))))) | ||
| 4677 | ;; Make the name unique by substituting directory | ||
| 4678 | ;; separators. It may not really be worth bothering about | ||
| 4679 | ;; doubling `!'s in the original name... | ||
| 4680 | (expand-file-name | ||
| 4681 | (subst-char-in-string | ||
| 4682 | ?/ ?! | ||
| 4683 | (replace-regexp-in-string "!" "!!" file)) | ||
| 4684 | backup-directory))) | ||
| 4675 | (expand-file-name (file-name-nondirectory file) | 4685 | (expand-file-name (file-name-nondirectory file) |
| 4676 | (file-name-as-directory abs-backup-directory)))))) | 4686 | (file-name-as-directory abs-backup-directory)))))) |
| 4677 | 4687 | ||