Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run Emacs when SSH-ing 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 /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 !!!

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 /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?

like image 910
Velimir Mlaker Avatar asked Mar 29 '14 19:03

Velimir Mlaker


People also ask

Can you use Emacs over SSH?

Emacs Tramp Brings Your Server Into Emacs These tasks can be easily accomplished with a basic terminal emulator and SSH. You can log into your server, run scripts, edit files, and do all the work you need to do.

How do I access Emacs on Mac?

You can find precompiled versions of emacs and Emacs. app at http://emacsformacosx.com/. Versions of macOS prior to 10.15 Catalina include a copy of GNU Emacs 22 without GUI support compiled in and thus Emacs is automatically available on all but the most recent versions of macOS via the terminal.


2 Answers

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.

like image 156
Stefan Avatar answered Sep 28 '22 00:09

Stefan


With Mac Ports x11 or gtk variant has to be selected, like this:

sudo port install emacs +x11

or that:

sudo port install emacs +gtk
like image 33
mariusm Avatar answered Sep 27 '22 23:09

mariusm