From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <83efoj61f5.fsf@gnu.org> References: <87y3mrljmq.fsf@gmx.de> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1511806096 7165 195.159.176.226 (27 Nov 2017 18:08:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 27 Nov 2017 18:08:16 +0000 (UTC) Cc: 29440@debbugs.gnu.org, shuguang@gmail.com To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 27 19:08:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJNp7-0001A8-Vw for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Nov 2017 19:08:06 +0100 Original-Received: from localhost ([::1]:34103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJNpF-0001gL-D1 for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Nov 2017 13:08:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJNp8-0001f0-09 for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2017 13:08:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJNp4-0001TV-1I for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2017 13:08:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52527) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eJNp3-0001TJ-Ti for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2017 13:08:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eJNp3-0000VC-OD for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2017 13:08:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Nov 2017 18:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29440 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29440-submit@debbugs.gnu.org id=B29440.15118060521886 (code B ref 29440); Mon, 27 Nov 2017 18:08:01 +0000 Original-Received: (at 29440) by debbugs.gnu.org; 27 Nov 2017 18:07:32 +0000 Original-Received: from localhost ([127.0.0.1]:32975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJNoZ-0000UM-Qy for submit@debbugs.gnu.org; Mon, 27 Nov 2017 13:07:32 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJNoY-0000U7-3s for 29440@debbugs.gnu.org; Mon, 27 Nov 2017 13:07:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJNoP-0000sL-Tj for 29440@debbugs.gnu.org; Mon, 27 Nov 2017 13:07:25 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56605) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJNoP-0000s2-Qy; Mon, 27 Nov 2017 13:07:21 -0500 Original-Received: from [176.228.60.248] (port=2316 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eJNoP-00056R-8s; Mon, 27 Nov 2017 13:07:21 -0500 In-reply-to: <87y3mrljmq.fsf@gmx.de> (message from Michael Albinus on Mon, 27 Nov 2017 18:24:45 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:140466 Archived-At: > From: Michael Albinus > 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?