how to run Emacs when SSH-ing from Linux to Mac OS X (with XForwarding)?

emacs, linux, macos, ssh

Solution

The `Emacs.app` binary is built to use Mac OS X's window system (we call it "ns" around here), which has nothing to do with X11, so you can't forward it over the network to another host. Instead, you want to install another Emacs on your Mac, which is built to use the X11 window system (so you can use it locally via Xquartz (which lets X11 clients use the native Mac OS X display), or you can use it remotely like any other X11 client).

The easiest way is probably to built it yourself: get the `emacs-24.3.tar.gz` source code and compile it with `./configure --with-x; make`.

Problem

At work I get a choice of two laptops to use, Windows or Mac. Being a linux guy, I thought the MacBook Pro will be a good fit. So I bring the MacBook Pro laptop home, and realize it doesn't have a right-ctrl key. And the bottom panel is annoying as hell. So I say, no problem, I'll sort all that out later, for now I'll use it as a server and remotely ssh into it from my crispy Xfce workstation environment. Well... I've spent about a day trying to figure out: How to ssh into the mac from my Fedora workstation, run emacs and have it show up (XForwarded) on my linux workstation ? You know like this: I've installed XQuartz and changed `/etc/sshd_config` and `/private/etc/sshd_config` with: ``` X11Forwarding yes XAuthLocation /opt/X11/bin/xauth ``` Mind you, `xeyes` works, and so does `xclock`, yay !!! Apparently X forwarding is working okay, since other gui apps are showing up remotely. But as for Emacs, foggetaboutit. The default Emacs from `/usr/bin/emacs` just runs it in `-nw` mode. Then I've installed the latest Emacs 24.3 (into `/Applications/Emacs.app/Contents/MacOS/Emacs`). This time, if I'm physically logged into the laptop (i.e. from the laptop keyboard) running Emacs from ssh shows up on the laptop's screen !!! WTF? If I logout of the laptop, then I get: ``` _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. ``` I'm at my wits ends. Any ideas why other X apps work? Anything special about Emacs?

Original source