[Top][All Lists]

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

Re: Emacs syntax for filenames to mean "absolute location on the current

From: Michael Albinus
Subject: Re: Emacs syntax for filenames to mean "absolute location on the current remote host"?
Date: Fri, 01 Sep 2023 20:13:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

>>> The one edge case I'm not quite sure what to do about is: how should
>>> we spell "the user's home directory on localhost"? Using "/:~" *could*
>>> work (in that Eshell could recognize it and do the right thing), but
>>> it's also the way that you spell "the file named ~" elsewhere in
>>> Emacs. (Eshell would spell that \~ or '~'). Maybe that's not such a
>>> big deal though: we can just document this corner case and hope users
>>> don't get *too* confused.
>> IIUC, "~" in a file name means always the home directory when it is
>> the
>> first character (of the local part in remote file names), or it comes
>> after a slash like in "/~". See (info "(elisp) File Name Expansion")
> The main thing I'm worried about is this: if we say that in Eshell,
> "/foo/bar" is relative to the current remote host, then the same
> should be true for "~": it would refer to your remote homedir when
> applicable.
> Then we'd want a way to refer to your *local* homedir no matter where
> you are. If we use "/:/foo/bar" to refer to the always-local
> "/foo/bar", then we might say "/:~" means your local homedir. But the
> Emacs manual says:
>> ‘/:’ can also prevent ‘~’ from being treated as a special character
>   for a user’s home directory.
> So according to that rule, "/:~" would mean "the file named tilde in
> the current directory".

Hmm, I've never stumbled over this sentence in the manual. And it is a
little bit vague: "can also prevent".

A short test shows that it doesn't if the tilde comes directly after the 

--8<---------------cut here---------------start------------->8---
M-x cd RET /net RET
M-x pwd
  => /net
M-x cd RET /:~ RET
M-x pwd
  => /home/albinus

M-x cd RET /:~user RET
M-x pwd
  => /home/user
--8<---------------cut here---------------end--------------->8---

It even works for remote file names (although there are still some quirks):

--8<---------------cut here---------------start------------->8---
C-x C-f /ssh:ford:/:~ RET
  => dired buffer of remote user's home directory
--8<---------------cut here---------------end--------------->8---

What doesn't work are file names like "/:/tmp/~hack", as said in the manual.

> I *think* what we'd want to do is to say, "Eshell's quoted file names
> work slightly differently from quoted filenames elsewhere in
> Emacs. Since Eshell expands tildes in file names on its own, '/:~'
> always means your local home directory. If you want to refer to a file
> whose name is tilde, you can use Eshell's escape sequences (etc,
> etc)."

Perhaps it is sufficient to point to the above restriction? And in some
Eshell commands, the local home directory is given simply by the absence
of an argument, like in "cd".

> I'll try to put together a patch that does this, and then people can
> try it out and see if it makes sense.


Best regards, Michael.

reply via email to

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