all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: emacs-devel@gnu.org
Subject: Re: Emacs syntax for filenames to mean "absolute location on the current remote host"?
Date: Tue, 29 Aug 2023 22:07:37 -0700	[thread overview]
Message-ID: <3ba84988-49d4-1a9f-471b-0436658c6ee2@gmail.com> (raw)
In-Reply-To: <877cpeuwyi.fsf@gmx.de>

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.



  parent reply	other threads:[~2023-08-30  5:07 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 [this message]
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

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

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

  git send-email \
    --in-reply-to=3ba84988-49d4-1a9f-471b-0436658c6ee2@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.