GNU bug report logs -
#29440
Tramp put drive_c in the backup file name when backuping in local PC/windows
Previous Next
Reported by: Shuguang Sun <shuguang <at> gmail.com>
Date: Sat, 25 Nov 2017 17:27:01 UTC
Severity: minor
Fixed in version 26.1
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
Full log
Message #17 received at 29440 <at> debbugs.gnu.org (full text, mbox):
> From: Michael Albinus <michael.albinus <at> gmx.de>
> Date: Mon, 27 Nov 2017 18:24:45 +0100
> Cc: 29440 <at> 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 <at> 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 <at> 192.168.178.30!\\home\\albinus\\tmp\\123".
> And (expand-file-name ...) returns then "c:/plink!albinus <at> 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 <at> 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 <at> 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 <at> 192.168.178.30!!!home!albinus!tmp!123"
WDYT?
This bug report was last modified 7 years and 184 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.