Tuesday, March 1, 2011

Launching server emacs from shell

I'm in a class that uses an implementation of Emacs on a school server. I'm on a mac running snow leopard, and I have my own implementation of Emacs on it. To access the server-Emacs, I ssh into the server and launch Emacs from its location there.

I'm relativly new to emacs, and I have a particular problem whenever I try to access the server-emacs from my local-emacs' shell-mode, having ssh'd into the server. It gives me the error that "Screen size -1x80 is too small", and doesn't launch the server-emacs.

I've the separate issue that when I try to do this in Apple's terminal, it does launch the server-emacs, but I really, really dislike the interface when emacs is launched within a terminal.

I've tried a couple of times to launch the server-emacs within a new window, in both scenarios, but apparently I'm not doing it right.

From stackoverflow
  • I think it'd be useful to understand what you're trying to do.

    Do you just want to edit files on the server? If that's the case, read the documentation for tramp, and try:

    C-x C-f //user@server:/path/to/file
    

    If you really want to use the emacs running on the server, try creating a frame on your

    (if so, look up tramp) If you want to actually use the emacs from the server, but have the window display on your mac:

    ssh server
    setenv DISPLAY mymac:0
    emacsclient file &
    

    This does assume you're running X11, and know how to resolve the display for your Mac. You can get X11 for the Mac here.

    Brian Postow : Doesn't this only work 1) if you are running XWindows and 2) if you know the name of your home display? Both of which are do-able, but should be mentioned.
    Trey Jackson : Good points, I thought about them, but am not positive. My wife's Mac is on the table across from me, but no Emacs on it... I opened a shell, but no DISPLAY variable.
    KLR : Unfortunately, I do need to use the server version, as my professor has it customized just as he likes it, and I don't want to implement some of his customizations on my local emacs. I tried the DISPLAY bit, briefly, but it errored out on the setenv section. I do have X11, so I don't know. I'll go hunt up some documentation and take a longer look at it after class today.
    Trey Jackson : If it's just a matter of using those customizations, you can have a different .emacs file and start emacs like: `emacs -q -l .professor.emacs`...
    Brian Postow : Yes, Trey is correct. Just use the profs .emacs (or .elisp folder or whatever) when you run it on your mac. You can also do a M-x load-file which will load in an arbitrary .el file once you've run emacs...
  • I think that Trey Jackson's suggestion of tramp (or the more old-fashioned 'ange-ftp) is probably your best bet.

    In general, running emacs inside an emacs is never a good idea. You either want to run emacs on the server (in -nw mode inside the terminal, or via some $DISPLAY magic) or run it on your mac (via tramp). There isn't really a good way to do both.

    KLR : Out of curiosity, why is it bad?
    Brian Postow : Well, first there's really no reason to do it. But mainly that you then have to figure out who gets what modifiers... Does control go to the local emacs? or the server emacs? what is the Meta key for each? Mouse clicks will only go to the local emacs... And in any case' you're going to end up using the SSH version of the UI anyway...
    KLR : Makes sense. Thanks.
  • It's a bit hard to tell what you are doing, but you probably want to ssh to the server with an X tunnel, then run emacs there which will pop up the window on your mac.

    First, don't use Terminal.

    On your mac, start up X11 (google for XQuartz if you don't already have it). Start up an XTerm (it should do this by default). From that XTerm, ssh to your server with the -Y option:

    ssh -Y me@server.something

    This should get you a remote shell and setup the DISPLAY environment to tunnel right back to your Mac's X server. Test it by running an xterm from there. If that works, you can instead run emacs. If that works, you can combine it with the ssh invocation:

    ssh -Y me@server.something /usr/bin/emacs # or whatever path you need

    You should set up ssh to not require a password but that's more than you asked for.

0 comments:

Post a Comment