[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#29440: Tramp put drive_c in the backup file name when backuping in l
From: |
Eli Zaretskii |
Subject: |
bug#29440: Tramp put drive_c in the backup file name when backuping in local PC/windows |
Date: |
Mon, 27 Nov 2017 20:07:10 +0200 |
> From: Michael Albinus <michael.albinus@gmx.de>
> Date: Mon, 27 Nov 2017 18:24:45 +0100
> Cc: 29440@debbugs.gnu.org
>
> When I enter line 4422, the (when (memq system-type '(windows-nt ms-dos
> cygwin))
> part, backup-directory is
> "c:/Users/lb01177/AppData/Roaming/.emacs.d/backup", and file is still
> "/plink:albinus@192.168.178.30:/home/albinus/tmp/123". As expected.
>
> The interesting part is here:
>
> --8<---------------cut here---------------start------------->8---
> ;; Replace any invalid file-name characters (for the
> ;; case of backing up remote files).
> (setq file
> (expand-file-name (convert-standard-filename file)))
> --8<---------------cut here---------------end--------------->8---
>
> (convert-standard-filename file) returns
> "\\plink!albinus@192.168.178.30!\\home\\albinus\\tmp\\123".
> And (expand-file-name ...) returns then
> "c:/plink!albinus@192.168.178.30!/home/albinus/tmp/123".
>
> Unexpected, indeed. I believe, this must be fixed, because "c:" is
> converted to "/drive_c" later on. The final backup name is
> "c:/Users/lb01177/AppData/Roaming/.emacs.d/backup/!drive_c!plink!!albinus@192.168.178.30!!!home!albinus!tmp!123.~3~"
>
> Eli?
The code there is inappropriate for remote file names, it assumes a
local file name. A remote file name should be processed as follows:
. remove the leading slash
. run the result through convert-standard-filename
. then do this:
(expand-file-name
(subst-char-in-string
?/ ?!
(replace-regexp-in-string "!" "!!" file))
backup-directory))
With your example, this produces
"c:/Users/lb01177/AppData/Roaming/.emacs.d/backup/plink!!albinus@192.168.178.30!!!home!albinus!tmp!123"
Or maybe prepend a slashe before calling subst-char-in-string? That
would produce
"c:/Users/lb01177/AppData/Roaming/.emacs.d/backup/!plink!!albinus@192.168.178.30!!!home!albinus!tmp!123"
WDYT?