4 ms·
>A saner approach would be based on a local editor editing remote files. Yes, this is the basis of the very popular and widely used TRAMP component in Emacs.
by catern 9y ago
>A saner approach would be based on a local editor editing remote files.
Yes, this is the basis of the very popular and widely used TRAMP component in Emacs.
>Imagine if you could type ‘edit foo.conf’ on the server and have it pop open a native editor on the client side.
Yes, this is possible with emacsclient.
- comex 9y agoAre you sure? I don’t have any experience with Emacs, but… > Yes, this is the basis of the very popular and widely used TRAMP component in Emacs. I’m sure TRAMP is better than vim’s netrw, but at least according to [1] it’s not fully asynchronous. It also seems to require a separate SSH invocation; I know you can configure SSH to reuse physical connections, but at least when I once tried it, it didn’t work very well… > Yes, this is possible with emacsclient. Judging by [2], it doesn’t seem to work well for that use case (talking to emacs over an SSH tunnel)… Assuming you can get it to work, can you make it work with multiple SSH connections to arbitrary servers, without any per-server configuration? If so, that’s quite interesting and maybe I should check it out. If not, then it still may be quite useful, but it wouldn’t be versatile enough to truly render editor-over-SSH unnecessary. [1] https://www.reddit.com/r/emacs/comments/23dm4c/is_it_possible_to_make_tramp_not_block_all_of/ https://www.reddit.com/r/emacs/comments/23dm4c/is_it_possibl... [2] https://emacs.stackexchange.com/questions/15144/emacsclient-to-access-remote-emacs-server https://emacs.stackexchange.com/questions/15144/emacsclient-...
- catern 9y agoTRAMP reuses ssh connections. It's straightforward to configure OpenSSH to reuse its connection, see e.g. https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing and that is what TRAMP does. >Can you make it work with multiple SSH connections to arbitrary servers, without any per-server configuration? Certainly, of course. Depending on your level of hackery, you can: - Make ssh automatically copy an emacsclient wrapper script over which does the correct thing - Use OpenSSH's Unix socket forwarding on each connection to connect emacsclient to your local Emacs server - Use https://github.com/magit/with-editor https://github.com/magit/with-editor I've never bothered, though, because I run all my shells on remote hosts via TRAMP within Emacs, so when I am in a shell, I can just use open the remote files through the normal Emacs keybindings, rather than typing "emacsclient filename". Thanks to with-editor, this also extends automatically to commands invoked on the remote host which run $EDITOR. >I don’t have any experience with Emacs, but… It's not surprising. :) You said "using vi over ssh - or any editor - has always struck me as a hack", "is an unpopular opinion". In fact, it's the consensus in Emacs land. :) Though perhaps that doesn't prevent it from being an unpopular opinion, these days. :)