13.2.1 "But I Already Have Emacs"
Mac OS X comes with a version of Emacs installed: 21.2.1 with Panther (10.3.2) and 21.1.1 with Jaguar (10.2.8). To start this version, use the Terminal application in your Utilities folder (which is inside the Applications folder) and just type emacs.
Figure 13-3shows the built-in Emacs running in the Terminal application.
Figure 13-3. The Terminal-based Emacs built into Mac OS X
But you should be aware that although it is built-in and certainly the easiest to start using, this version of Emacs has a few shortcomings:
1. It runs, well, you know, in a Terminal.
2. It does not have any of the graphical user interface features such as icons or expected mouse behavior.
3. The Terminal application often supersedes Emacs when handling things like the scrollbars and some key bindings.
If you can live with those restrictions—or have no choice—then feel free to skip the next section on installing Emacs and get on with using the version you have. The vast majority of information in this book still applies.
13.2.2 Installing Prebuilt Emacs on Mac OS X
What if you want the latest version of Emacs but don't want to build it yourself? After all, not every Mac OS X user is an old Unix hack! Mac systems made a name for themselves by providing some of the best user interface conventions around in a single, good-looking package. That hasn't changed. If you're not a big fan of do-it-yourself application building, you can download a nifty application bundle and just drag-and-drop your way to a recent build of Emacs.
13.2.2.1 Downloading Alex Rice's application bundle of Emacs 21.3.5
Most Mac users will want to grab a prebuilt binary version of Emacs that's all ready to go. Alex Rice created just such a build. It can be found online (for free! [91]) at: http://mindlube.com/products/emacs/index.html. You can download directly from that page, but be sure to grab the correct version. You can pick from the Jaguar (Mac OS X 10.2) version or the Panther (Mac OS X 10.3) version.
You'll be downloading a .dmg file which is the Mac disk image format. It should automatically unpack and mount itself, but if it doesn't for some reason, just double-click on the .dmg file after it is completely downloaded.
As it launches, you'll need to read and agree to the license. After you do that, you should have a new "disk" mounted and you'll see the Emacs application all ready to drag and drop. (See Figure 13-4.)
Figure 13-4. The mounted disk image for Emacs on Mac OS X (Panther)
Drag the big gnu to your Applications folder and off you go. That really is all there is to it. Many, many thanks to Alex Rice and Mindlube! (And feel free to eject the mounted image once you have copied Emacs to your hard drive.)
13.2.3 Building Emacs from Source on Mac OS X
While Mac OS X is based (very squarely) on Unix, as of build 21.3.5, your best bet for building Emacs is still to go with a slightly modified build process. (The Mac build should join up with the normal build in version 21.4.) Until 2004, that separate process was maintained by Andrew Choi and made available to the public at http://members.shaw.ca/akochoi-emacs/. Fortunately, it is still available there, although Andrew is no longer the Mac maintainer.
Tip
Full instructions on the build can also be found at Andrew's site. While the build is essentially the same as it is for other Unix systems (you run configureand then make), retrieving the source code is best done through CVS to get the latest version. If you have installed the Mac Developer Tools CD, you'll have CVS. If you haven't installed the Mac Developer Tools (usually available on a separate CD that came with your Mac or with your copy of Mac OS X), you must; the Developer Tools are required to build version 21.3 from source.
13.2.3.1 Before you build
For the 21.3 build, Andrew Choi has posted the steps required to retrieve and build Emacs at http://members.shaw.ca/akochoi-emacs/stories/obtaining-and-building.html.
If you plan to go this route on Panther (Mac OS X 10.3), just follow Andrew's instructions. Alternatively, you can follow the Unix build instructions from the previous section. If you're still running Jaguar, you'll need to do a bit of preparatory work. Read on.
13.2.3.1.1 Jaguar (Mac OS X 10.2) preparation
The first of the extra notes is that you should upgrade to Panther (10.3) if you aren't there already. Seriously. There are lots of benefits. But if that's just not in the cards for you, you do need to take a small detour before installing Emacs.
Mac OS X 10.2 lacks a piece of software required for Emacs: texinfo. (That tool comes preinstalled on 10.3.) It's not hard to install; you just have to remember to do it. You basically install the texinfopackage as you would if any other Unix package. You can look back at the previous section for more details, but here are the basics.
You'll need to perform these commands from the Terminal application. By default, Terminal starts you out with a C-Shell variant, so we'll use the % character for the prompt in the commands for this section.
1. Pull the texinfopackage from the /pub/gnu/texinfo folder at ftp.gnu.org . The compressed archive file will be called something like texinfo-4.7.tar.gz . Grab the latest version available.
2. Unpack the archive.
% tar xvzf texinfo-4.7.tar.gz
If you downloaded texinfothrough a browser, chances are the browser uncompressed it for you. Some of them might even have unpacked it as well. If you have a . tar file sitting on your desktop, you can unpack it like this:
% tar xvf texinfo-4.7.tar
3. Move to the texinfo-4.7 directory and configure your build.
% ./configure
4. Assuming that all goes well, you can build everything:
% make
5. And assuming that went well, you can install it. But you'll have to do that as an administrator. Fortunately that's easy to do in the Terminal window. Just run this command:
% sudo make install
You'll be prompted for your password. Type it in and everything should go well. If you aren't allowed to administer your own machine, you'll need the help of someone who does have admin privileges.
Now that you've installed texinfo, you'll need to download, unpack, and install Emacs, either by following Andrew Choi's instructions or ours in the "Emacs and Unix" section earlier in this chapter.
Your Mac build should end up creating a double-clickable icon that you can drag and drop into your Applications folder just like the prebuilt download.
13.2.4 Starting Emacs from the Command Line on Mac OS X
On Mac OS X, you have Emacs preinstalled, but as we know, it is an older version of Emacs. Let's say that you have installed the graphical version and want to start it with some command-line arguments. For example, you might want to run emacs —debug-initto debug your .emacs file. The Mac OS X Gnu icon certainly should be a permanent fixture on your Dock, but at times the command line is the way to go.
We learned this trick from Andrew Choi's Mac OS X FAQ, and we share it here, slightly tweaked, for convenience. Check out his page at http://members.shaw.ca/akochoi-emacs/stories/faq.html.
Читать дальше