Velimir Mlaker Velimir Mlaker - 2 months ago 5
Linux Question

how to run Emacs in "ssh -X" from Linux to Mac OS X (with XForwarding)?

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:

enter image description here

I've installed XQuartz and changed


X11Forwarding yes
XAuthLocation /opt/X11/bin/xauth

Mind you,
works, and so does
, yay !!!

enter image description hereenter image description here

Apparently X forwarding is working okay, since other gui apps are showing up remotely. But as for Emacs, foggetaboutit.

The default Emacs from
just runs it in
mode. Then I've installed the latest Emacs 24.3 (into
). 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?


The 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.