unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs syntax for filenames to mean "absolute location on the current remote host"?
@ 2023-08-29  3:51 Jim Porter
  2023-08-29  7:30 ` Michael Albinus
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Porter @ 2023-08-29  3:51 UTC (permalink / raw)
  To: emacs-devel

In Emacs, is there a way of spelling a file name to mean "an absolute 
name on the current remote host"? We have a way of spelling an absolute 
name on the local host ("/foo/bar"), and an absolute name on a specific 
remote ("/method:host:/foo/bar"), but I'm not aware of a way to make a 
string that means the equivalent of:

   (concat (file-name-remote-p default-directory) "/foo/bar")

Do we have a syntax for this? If not, could we add one? Maybe something 
like "/.::/foo/bar"? That would be a remote file name with the method of 
"." - i.e. "the current method" and no hostname (it would be inferred 
from the current remote).

----------------------------------------

If you'd like to know why I'm asking, read on. But be warned: I'm still 
trying to reason through all the logic here myself, so this may be a bit 
confusing (it certainly is for me!).

This is relevant for Eshell. In Eshell, you SSH into other hosts simply 
by using "cd /ssh:user@host:~". This is very convenient, but it produces 
some odd effects: when you're on a remote host like this, the meaning of 
"/foo/bar" is ambiguous. If you pass that to a command, it could mean:

   1) "/foo/bar" on your local filesystem (when the command is an Emacs 
Lisp function)

   2) "/foo/bar" on "host" (when the command is an external process)

To make matters more confusing, some Eshell commands implemented in Lisp 
will fall back to an external process if the Lisp version can't do what 
you asked, meaning that you need to know Eshell *very* well to be sure 
what will happen in these cases.[1]

To get around this, what if Eshell had a way of unambiguously referring 
to absolute file names, whether on your local system or the current 
remote host? For the local system, we already have a syntax available: 
quoted file names (e.g. "/:/foo/bar"). However, we'd need one for the 
current remote host too (see above).

As an addendum: it would be nice to have "/foo/bar" be usable too (i.e. 
not have this weird inconsistency). However, I think we'd need to 
perform some translations in Eshell to make this work, and I think 
that'd need to be defined on a per-command basis, so there would end up 
being cases where that broke. Unambiguous syntaxes would let us avoid 
that in the general case (at the cost of more typing).

[1] There's an optional Eshell module called "Electric Slash", but it 
doesn't handle this more-complex scenario.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-09-02 11:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2023-09-01 18:36           ` Jim Porter
2023-09-01 19:23             ` Jim Porter
2023-09-02 11:20               ` Michael Albinus

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