Clementson's Blog

Bits and pieces (mostly Lisp-related) that I collect from the ether.

October 2007
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Sep  Nov

Emacs Running All The Time

Monday, October 1, 2007

I love working in Emacs; however, it can be irritatingly slow when starting up (it's funny how a few seconds seems sooo slllooowwww these days!). This is normally not a big deal, but you tend to notice it more if you want to view a document and you have to wait a few seconds for Emacs to startup. Like a lot of long-time Emacs users, I try to avoid this minor aggrevation by not shutting down Emacs. Unfortunately, in addition to using Emacs for "real work", I compulsively tinker with my Emacs setup. Not just every now and then, but a lot. And, although I know how to unload modules and back out changes, sometimes it is easier to just restart Emacs rather than try to "uninstall" things. The problem is that there are things that I don't want to kill (for example, I use Gnus for reading mail and Usenet news, jabber.el for IM, and ERC for IRC and I don't want to have to restart them all the time). So, I usually keep a terminal emacs running in addition to an instance of Aquamacs Emacs. I tend to use terminal Emacs as my "stable" Emacs for mail/IRC/IM/etc and Aquamacs Emacs as my main development Emacs. There are a number of things that I've done to facilitate this "multi-Emacs" setup:

  1. Emacs: I usually run with the latest version of Aquamacs Emacs (either release or CVS) as I consider it the best Emacs distribution for Mac OS X. Since the CVS versions of Aquamacs Emacs are based on the CVS version of Emacs, it's also a convenient way to stay current with the latest developments in CVS Emacs. So, I like to use the emacs executable that is installed with the Aquamacs application instead of whatever is currently in "/usr/bin/emacs". Therefore, I have my .bashrc and some shell scripts setup to ensure that my terminal Emacs is the same as the one included in Aquamacs (I can always override that by explicitly specifying "/usr/bin/emacs" if I need to).
  2. EmacsClient: I wanted to have a consistent way of sending things to Emacs regardless of whether I had a terminal Emacs open or Aquamacs Emacs and regardless of whether I was sending the document from a command line or from a Mac application to Emacs. I do this by having an "emacsclient.app" application setup (as described in an earlier post) as well as using the conventional emacsclient program. For a lot of document types, I set the default Application to be emacsclient.app. However, I can send any document to Emacs by right-clicking on a file and selecting "Open With" emacsclient.app.
  3. Bash/Screen: I posted previously on how great the "screen" utility is. I run my terminal Emacs inside of screen. However, I have my .bashrc and .screenrc initialization files setup so that every time I run Terminal.app I either get a new screen session or reconnect to an existing one (a variation on what is described here and here)
More specifically, I have the following setup: This all probably sounds a lot more complicated than it really is. But, with this setup, I always have a "working" Emacs (my terminal Emacs) that I can send documents to if Aquamacs Emacs isn't running. Even if I accidentally kill Terminal.app, my terminal Emacs session is still running in screen so it will be there when I next startup Terminal.app. Most of my "heavy duty" editing work will be done in Aquamacs Emacs; however, if I need to view a file and Aquamacs Emacs isn't running for some reason, the terminal screen Emacs is always available.

At some stage, the upcoming Emacs multi-tty support will probably eliminate a lot of the need for my current dual-Emacs configuration. However, in the meantime, it works nicely for me! :-)

Update-2007-10-02: I originally had in my .screenrc file these lines:
hardstatus on                                         
hardstatus alwayslastline                                                                                                 
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
However, Johannes Weiner pointed out that this could be replaced by:
hardstatus alwayslastline "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
So, I changed it. Somehow, it always feels nicer to remove lines of code! ;-)

emacs Copyright © 2007 by Bill Clementson