18.16 Quoted File Names
You can quote an absolute file name to prevent special characters and syntax in it from having their special effects. The way to do this is to add β/:
β at the beginning.
For example, you can quote a local file name which appears remote, to prevent it from being treated as a remote file name. Thus, if you have a directory named /foo:
and a file named bar
in it, you can refer to that file in Emacs as β/:/foo:/bar
β.
If you want to quote only special characters in the local part of a remote file name, you can quote just the local part. β/ssh:baz:/:/foo:/bar
β refers to the file bar
of directory /foo:
on the host baz
.
β/:
β can also prevent β~
β from being treated as a special character for a userβs home directory. For example, /:/tmp/~hack
refers to a file whose name is ~hack
in directory /tmp
.
Quoting with β/:
β is also a way to enter in the minibuffer a file name that contains β$
β. In order for this to work, the β/:
β must be at the beginning of the minibuffer contents. (You can also double each β$
β; see File Names with $.)
You can also quote wildcard characters with β/:
β, for visiting. For example, /:/tmp/foo*bar
visits the file /tmp/foo*bar
.
Another method of getting the same result is to enter /tmp/foo[*]bar
, which is a wildcard specification that matches only /tmp/foo*bar
. However, in many cases there is no need to quote the wildcard characters because even unquoted they give the right result. For example, if the only file name in /tmp
that starts with βfoo
β and ends with βbar
β is foo*bar
, then specifying /tmp/foo*bar
will visit only /tmp/foo*bar
.