emacs-devel
[Top][All Lists]
Advanced

[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: Jim Porter
Subject: Re: Emacs syntax for filenames to mean "absolute location on the current remote host"?
Date: Tue, 29 Aug 2023 22:07:37 -0700

On 8/29/2023 12:30 AM, Michael Albinus wrote:
Thinking about, it seems we need this *only* in Eshell. And then the
need isn't such obvious.

Yeah, I wasn't sure if there was something I could easily piggyback off of for Eshell, or if it would take a lot of effort to make an Emacs-wide way of doing this.

What if you declare, that in Eshell an absolute file name "/foo/bar" is
always on "host"? Then it doesn't matter, whether a user writes "cd /foo/bar"
or "*cd /foo/bar". This would cover most use cases in Eshell, and it is
simpler to type than "cd /.:/foo/bar".

My main worry is that we only want to do this for absolute file names, not just things that *look* like absolute file names. For example "/foo/" might be a regexp instead of a directory name. We could add special handling for commands where we know they take file names, but that's laborious, and we'd never cover everything.

I see a couple options:

* Eshell lets you escape characters so they have their literal meaning, like \$ or '$' (if you don't want to use dollar-expansion). We could do the same for a leading /. That is, /foo/bar (no quotes) would get automatically expanded to /method:host:/foo/bar when on host. '/foo/bar' would just remain as /foo/bar though.

* I realized an important part of the Eshell side: we have Eshell-only variables! I could define a variable that expands to '(file-remote-p)'. The only question is what to call it. For example, we could use $/ or $:, so a user could type $//foo/bar or $:/foo/bar. I think I like $:, but I'm open to other suggestions. For single-char variable names, we can use any symbol except: ( ) { } [ ] < > " ' @ # $ * + - _ ?

We could even do both of these, and provide a user option for enabling/disabling the first one. That way, with the first one enabled, you get something pretty close to ordinary shells. However, if you don't like it, you still have the latter as a more-explicit option. (The latter is nice too because it should be a single line of code to implement.)

In the few cases a user means the local absolute file name "/foo/bar",
she still can type "cd /:/foo/bar".

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.



reply via email to

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