unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Jim Porter <jporterbugs@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Emacs syntax for filenames to mean "absolute location on the current remote host"?
Date: Fri, 01 Sep 2023 20:13:08 +0200	[thread overview]
Message-ID: <874jkdrccr.fsf@gmx.de> (raw)
In-Reply-To: <0585b415-4b54-95c3-4454-9317d7a79c61@gmail.com> (Jim Porter's message of "Fri, 1 Sep 2023 10:36:56 -0700")

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 quoting:

--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.

Yep.

Best regards, Michael.



  reply	other threads:[~2023-09-01 18:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29  3:51 Emacs syntax for filenames to mean "absolute location on the current remote host"? Jim Porter
2023-08-29  7:30 ` Michael Albinus
2023-08-29 11:57   ` Eli Zaretskii
2023-08-30  5:07   ` Jim Porter
2023-08-31 13:58     ` Michael Albinus
2023-09-01 17:36       ` Jim Porter
2023-09-01 18:13         ` Michael Albinus [this message]
2023-09-01 18:36           ` Jim Porter
2023-09-01 19:23             ` Jim Porter
2023-09-02 11:20               ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jkdrccr.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=emacs-devel@gnu.org \
    --cc=jporterbugs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).