[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bad regexp in auto-save-file-name-transforms

From: Chris Moore
Subject: bad regexp in auto-save-file-name-transforms
Date: 09 Apr 2004 14:05:26 +0200

If tramp-auto-save-directory is nil, and I'm using tramp to edit a
file in the root directory of a remote machine, the auto-save
filename that is generated is bad.  It is supposed to be a local file
in a tmp directory, but it ends up being a remote file with a
different username.

The regexp in auto-save-file-name-transforms, defined in files.el has
this value by default:

The 2nd group is supposed to give just the remote file name, without
any slashes.

Here are some examples.  First an example of it working:

            file: "/address@hidden:/dir1/dir2/file.txt"
          group1: "/dir1/dir2/"
          group2: "file.txt"
  auto-save path: "/home/chris/tmp/address@hidden:!dir1!dir2!file.txt#")

Then an example of it failing:

            file: "/address@hidden:/file.txt"
          group1: nil
          group2: "/file.txt"
  auto-save path: "/home/chris/tmp//address@hidden:!file.txt#"

Notice the double / in the 2nd auto-save-path.  that makes the path
effectively the same as "/address@hidden:!file.txt#", which is
itself a tramp path, but with remote username "#!anon".  the user is
prompted for the password of user "#!anon", somewhat confusingly.

The solution is to ensure that the 2nd group in the regexp doesn't
include the "/".  I propose changing the regexp in
auto-save-file-name-transforms as follows:

--- Backup/files.el.~1~ 2004-04-02 17:12:48.000000000 +0200
+++ files.el    2004-04-09 13:49:58.634318672 +0200
@@ -293,7 +293,7 @@
   :group 'auto-save)
 (defcustom auto-save-file-name-transforms
-  `(("\\`/[^/]*:\\(.+/\\)*\\(.*\\)"
+  `(("\\`/[^/]*:/?\\(.+/\\)*\\(.*\\)"
      ;; Don't put "\\2" inside expand-file-name, since it will be
      ;; transformed to "/2" on DOS/Windows.
      ,(concat temporary-file-directory "\\2") t))

With that change (to allow an optional / right after the :) the above
examples stay the same except that the slash in group2 disappears,
and the auto-save path is generated correctly.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]