UsingEmacs

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:

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.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact