Since Emacs speaks the X11 protocol, and the Mac desktop has an X11 server, you can work directly with Solaris on the Mac desktop. There is no need to visit the Gnome desktop, or to wait for a "Solaris Unity" mode in your VM software. Just run the Mac's X11 server, and do your work in Emacs.
Terminal Settings for Using TTY Emacs
When driving Emacs from a Mac terminal window, you'll need the Meta key. That's called the Option key on Mac, and since Option is used to form extended characters, it is not mapped to the Meta modifier by default.
- Select Terminal, Show Info (Command-I), select Keyboard Tab
- Check "Use option key as meta key"; press "Use Settings as Defaults"
You only need to drive Emacs from the Mac terminal long enough to issue the gnuclient command. After that, you will be driving Emacs via X11.
Stable screen sessions
It is best if you avoid tying your Emacs session to a particular login. This can be done with the screen program, which maintains sessions across multiple shell logins, as long as Solaris is not rebooted. Install screen from:
- visit http::/sunfreeware.com and download the ncurses and screen packages:
ftp://ftp.sunfreeware.com/pub/freeware/intel/10/ncurses-5.6-sol10-x86-local.gz
ftp://ftp.sunfreeware.com/pub/freeware/intel/10/screen-4.0.2-sol10-intel-local.gz - from a root shell within Solaris, install ncurses and screen:
# pkgadd -d ~/Downloads/screen-4.0.2-sol9-intel-local # pkgadd -d ~/Downloads/screen-4.0.2-sol9-intel-local
- test the installation by logging in from a Terminal window:
Welcome to Darwin! MyMac:~ joeuser$ ssh joeuser@solaris-devx.local Password: Last login: Sun Sep 02 10:05:06 2007 from macosx Sun Microsystems Inc. SunOS 5.11 snv_55 October 2007 $ /usr/local/bin/screen --version Screen version 4.00.02 (FAU) 5-Dec-03 $ /usr/local/bin/screen -xRR
Getting a Real Emacs Window
In order to run Emacs for real, you need to install X11 on your Mac. It is generally found in Applications/Utilities. From a Mac Terminal, try saying open -a X11.
The gnu Emacs and gnuclient programs are pre-installed in Solaris. But, for gnuserv/gnuclient to work solaris-devx must be known to itself. One way to do it is to edit /etc/hosts:
$ su # cp /etc/hosts /etc/hosts.bak # echo 172.16.135.128 solaris-devx solaris-devx.local >> /etc/hosts
From within screen, you can start an Emacs session that will survive as long as the Solaris VM continues to run. Because of snapshots, this means you can set up an Emacs session that is reusable even after Mac OS reboots.
- Terminal => New Shell
- Get ready for X11 action from Solaris:
open -a X11 xhost solaris-devx.local
- Log in to Solaris
$ ssh solaris-devx.local Password:
- Once in Solaris, start screen (or reconnect with it)
$ screen -xRR
- Once in the screen session, start Emacs in "no-window" mode.
$ DISPLAY=macosx:0.0 $ export DISPLAY $ /opt/SUNWspro/bin/xemacs -nw -f gnuserv-start
- Once the tty-mode emacs shows up, run gnuclient:
Meta-x shell (return) $ /opt/SUNWspro/bin/gnuclient
- When the X11 window comes up, you can immediately close the Terminal window, without further ceremony.
There are surely ways to streamline this process...
The following command has been known to work directly within Mac Terminal, but only after the emacs session has already been started (with gnuserv) and the xauth configuration is adjusted to allow it:
$ open -a X11 $ xhost solaris-devx.local $ gnuclient -display macosx:0.0 -h solaris-devx.local
The xauth setup is something like this, where the bracketed number must be replaced by a random one of your own choosing:
$ open -a X11 $ xauth add solaris-devx.local:999 MIT-MAGIC-COOKIE-1 <5551212> $ ssh joeuser@solaris-devx.local solaris-devx$ xauth add solaris-devx.local:999 MIT-MAGIC-COOKIE-1 <5551212>
Finger Sanity
Is it worth it? After all, Emacs has a notoriously strange way with accelerator keys. It has its own incompatible meaning for both Control-X and Meta-X (Option-X or Alt-X), which have nothing to do with cutting text. (But it came first, so who can blame it?) In order to switch quickly between Emacs and Mac without making your fingers want a divorce, you must convince Emacs to become more like the Mac. This involves changing most of the "Meta" keys to Mac-like bindings. Attached is an approach to doing this.