Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
384 views
in Technique[技术] by (71.8m points)

emacs - Using tramp with EmacsW32 and cygwin, possible?

I have some trouble setting up Tramp with EmacsW32 and cygwin. I have configured emacs to use cygwin as shell using w32shell. I also set the HOME enviromental variable to c:/cygwin/home/myusername

Problem is that tramp seems to hang and that no connection is made:

"Tramp waiting for prompts for the new shell".

I have tried to turn on debugging, but still only see this message. Looking forward to get some tips on this. Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As a foot note, I've since changed the way I use TRAMP under Windows.

TRAMP under Windows was simply too slow. The Control Master feature of OpenSSH was what I needed -- this keeps a persistent SSH connection open, therefore eliminating the costly connection that is otherwise required for every TRAMP operation. Unfortuntely, Cygwin is fundamentally incapable of supporting Control Master at this point in time :/

This being the case, my current solution is not to run Emacs in Windows at all. Instead I installed Cygwin's X.Org server, and started running Emacs on a GNU/Linux VM (hosted on my Windows box), and using the Cygwin X display.

This works really really well.

I'm running emacs in daemon mode, which means it doesn't matter if there are ever any issues with the X server, and if I need to shut down the Windows box, I can simply save the state of the VM, restore it afterwards, and not actually lose my session(*). (desktop.el provides pretty decent session management in any case, or if you need to reboot the VM; but if you're using that, you may wish to modify the desktop-files-not-to-save variable so that it doesn't ignore all of your TRAMP buffers! I just set it to "^$")

Be sure to start Cygwin's X server with startxwin rather than startx (the former enables the X server's windows to appear as regular Windows windows), and then from an xterm you can execute ssh -Y (me)@(linux) -f "emacs --daemon" to start the server initially, and ssh -Y (me)@(linux) -f "emacsclient -c" to start a new client.

The 'scpc' and 'rsyncc' TRAMP methods use Control Master automatically. I still run a ssh-agent on the Linux box, though (to avoid the need to authenticate when opening remote shells from emacs, etc). The 'emacs --daemon' command then becomes something like ssh -Y (me)@(linux) -f "source ~/.ssh/agent-environment && emacs --daemon", presuming that you directed/copied ssh-agent output to that file when you ran it (I don't bother with an identity time-out for this one).

And finally, on that last note, if you are using a similar mechanism to the one I originally mentioned for managing your cygwin ssh-agent in your bash_profile, take careful note of what happens when you start the X server from the Windows shortcut when you do not have an authenticated identity loaded -- nothing at all (until you look in the task manager, and see the ssh-add process sitting there). Consequently, I recommend always using startxwin from the command line, to avoid this.

edit:
(*) That was a bad assumption. I've since realised that restarting the X server actually does prevent me from reconnecting to the emacs daemon afterwards, which is rather unfortunate. Consequently I rely fully upon the desktop library to restore my session. I use auto-save-hook to regularly save my desktop file to keep it up to date. See the Emacs Wiki for this and other options for enhancing the Desktop feature.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...