Home » Linux Magazine » A Comparison of Xemacs and Gnu Emacs

A Comparison of Xemacs and Gnu Emacs

Larry Ayers

Issue #34, February 1997

Emacs aficionados will point out that Emacs is intended to be left running all of the time; in some ways the editor doubles as an operating environment or shell.

Introduction

Most Linux users have probably used the Gnu Emacs text editor at one time or another, if only out of curiosity. Originally intended as a programmer’s editor, Emacs has grown over the years, accreting to itself pieces of LISP code from a variety of contributors. Now one of the most common complaints about the editor is its sheer bulk and concomitant slowness to load. Emacs aficionados will point out that Emacs is intended to be left running all of the time; in some ways the editor doubles as an operating environment or shell. As high-speed CPUs, faster hard disks and larger amounts of RAM have become more affordable, this complaint is no longer as much of a concern as it once was.

Emacs makes up for this minor drawback by being very configurable and extensible. Name a function related to text and there is probably an Emacs mode that will facilitate it. Many people use Emacs as their sole mail and Usenet news client, while programmers will find code-editing, compiling, and debugging well supported for a variety of programming languages. You can syntax-highlight any sort of text or code. The shell mode allows input and output from your preferred shell to be the contents of a buffer, from which text can be cut and pasted into other buffers. The various modes such as mail, news and the programming-specific modules are loaded and unloaded as needed.

Though many people over the years have contributed modes and enhancements to Emacs, the program is still firmly controlled by Richard Stallman of the Free Software Foundation, who wrote the first version back in the mid-seventies.

Two Editors Diverged in a Yellow Wood…

Before Gnu Emacs became well integrated with the X Window System there arose a group of Emacs-users, both private and corporate, who were impatient with the pace of the progress Stallman and the FSF were making on the program. They initiated a project to improve the user interface of Emacs (especially the X Window System support) with the intention of eventually merging the two code lines together.

One of the companies involved, the now-defunct Lucid, Inc., gave its name to the first versions of this divergent Emacs; you may have seen archives of Lucid Emacs files on the Linux FTP sites or on archive CDs.

Lucid Emacs acquired a new name, Xemacs, when the Lucid company folded. The University of Illinois, Sun Microsystems and the Amdahl Corporation emerged as the primary institutional and corporate supporters of the program.

Over the next few years conflicts arose between the FSF and the Xemacs team. Richard Stallman agreed to incorporate the Xemacs code into Gnu Emacs, but the conditions he set were unacceptable to the Xemacs developers. A stalemate has resulted. It looks as if for the foreseeable future the two versions of Emacs will develop in parallel. On the one hand, this may seem like a lot of wasted effort, but on the other, an element of competition has been introduced which in some ways benefits the end-user.

The Free Software Foundation might have been tempted to rest on its laurels if not for Xemacs. After all, the Gnu Emacs of even a couple of years ago was quite a unique and respectable piece of software. Improvements in recent years are tending towards refinements and user-interface improvements. The basic editing functionality really doesn’t need much work.

Major Differences

Though both Gnu Emacs and Xemacs are programmed in the LISP programming language, the underlying structures are different enough that LISP add-on packages which work with one may not work with the other. Luckily many of the package maintainers are attempting to make their modules work with both Xemacs and Gnu Emacs, though the functionality may not be identical.

As an example, Bill Perry’s W3 package, which turns Emacs into the world’s only LISP-based web browser, works with both Emacsen (an odd term which is often used as a plural form of Emacs), but the Xemacs version will display inline images and backgrounds whereas Gnu Emacs won’t.

Xemacs features an iconic toolbar, and several modes, e.g., the aforementioned W3 and the VM mail mode, have their own toolbars which only appear in Xemacs, though otherwise the modes function well in Gnu Emacs.

Gnu Emacs is limited to fixed-width fonts, while Xemacs can use variable-width proportional fonts. This feature will be of little interest to programmers, as source code looks ragged and is harder to read with proportional fonts. I confess I’ve never felt the need for anything but fixed-width fonts in a text editor, but tastes and needs differ.

I’ve found a few packages which work only with Gnu Emacs. One is NC, which replaces the native Emacs directory browser, Dired, with a Norton Commander-like interface.

Installing Xemacs

Precompiled binaries for Linux and many other operating systems are available from ftp://ftp.xEmacs.org and its mirrors. Generally there is a common file which everyone needs; this contains the platform-independent LISP files and miscellaneous documentation, a mix of the GNU Emacs documents and Xemacs-specific stuff. A smaller file contains the binaries for your platform. For Linux there is a choice between statically-linked Motif executables, dynamically-linked Motif executables (for those who own a copy of the the Motif libraries), and dynamically-linked Athena executables; the latter is probably the best choice if you don’t have Motif.

If you want to compile your own executables, be prepared to make lots of disk space available. 70MB is a bare minimum (including the unpacked source code) that will work if you “compile in place”, i.e., the source-code directory will be where you leave Xemacs. This way the new executable refers to LISP files in the source directory. Otherwise you need another 50MB momentarily. The structure of the Xemacs directory tree is hard-coded into the executable; if you’d like to customise it the Makefile has paths that can be edited.

There are various reasons for compiling your own executable—perhaps you have no need of the icon toolbars. I’ve noticed that I rarely use them now that I’m more familiar with the equivalent keystrokes, and they do use memory you might not have to spare. The toolbar support (as well as the pop-up menu support) can be disabled at compile time, helping to create a leaner executable.

Another possible change is the inclusion of a frequently used package in the executable, rather than loading it separately from the ~/.Emacs initialization file.

Once you’ve unpacked the massive Xemacs archive files you may very well be dismayed by the amount of disk space they occupy. Luckily you can delete quite a bit of them and still have a great editor. If you look at the subdirectories under the LISP directory you will find many bulky packages for which you may never have a need, such as the Object-Oriented Browser and Hyperbole. If you have no desire to use Xemacs as a web browser (W3 is well-implemented but rather slow), the W3 and URL subdirectories can go. I recommend spending some time browsing through the LISP subdirectories; the un-byte-compiled *.el files are human-readable and most contain informative notes which will help you decide if you want to keep them or not. Another substantial amount of disk-space can be reclaimed by simply gzipping all of the *.el files; Xemacs doesn’t need them at all. The reason that they are included with Xemacs is to give users the opportunity to edit them in order to modify their behaviour. The byte-compiled *.elc files are what Xemacs actually uses.

Configuration

When either version of Emacs is started the program immediately checks your home directory for an .Emacs file. This LISP file tells Emacs which packages you would like loaded and can set a vast array of user choices. Xemacs comes with a sample.Emacs file (in the /etc subdirectory) that is well commented and includes several default functions which many have found useful. Even more useful is the version-detection code, which determines whether you are running Gnu Emacs or Xemacs and the version number. Separate sections of the file are read by corresponding versions of Emacs, allowing the use of the same .Emacs file for any version of Xemacs or Gnu Emacs.

This permits the user to have both Xemacs and Gnu Emacs installed and usable at the same time, allowing for comparison. Xemacs 19.14 refines this even further, putting its configuration in a separate file called ~/.xEmacs-options that is called from within the ~/.Emacs file.

Though the prospect of writing LISP code in order to introduce your own functions and modifications into your .Emacs file may seem daunting, learning by imitating what others have done can be effective as well. Another help is the detailed documentation supplied with both versions in the form of hierarchical Info files. Several skilled Emacs users have posted their personal ~.Emacs files on web pages; a search conducted with Lycos or Alta Vista for the keywords Emacs, Gnu Emacs, or Xemacs will easily find such pages.

Advantages of Gnu Emacs

Although at first exposure it may seem that Xemacs offers more to users, Gnu Emacs has certain features that will tip the scales in its favor for some people. If you have the GPM console mouse server installed (this is included in most distributions of Linux) Gnu Emacs interacts well with it, giving full mouse support in console mode. Xemacs has limited mouse functionality in a console session, but has the advantage of full face support in a console, i.e., syntax highlighting will work in a console session, although without as many colors as in an X session.

Gnu Emacs has a convenient editing feature: text copied or cut from a file can be accessed from a pull-down menu on the menu bar, with each piece of text identified by its first few words. While there is a way to implement a similar function in Xemacs, it’s not documented in the distribution.

If memory usage is a factor for you, Gnu Emacs typically uses about 2MB less than Xemacs, and its startup time is slightly shorter. Of course, if you would like a lean, low-memory version of either Emacs, you can compile without X Window System support.

Safety

Both versions of Emacs protect you from losing files or unsaved text. As you type, the current buffer is periodically saved (at user-configurable intervals) to a file called “#filename#”, which can be restored in a later editing session. As soon as a file is successfully saved, this temporary file is automatically deleted. The normal type of backup file (filename~) is also created when files are saved. It would be difficult to lose very much text with these safeguards in effect.

Interesting Packages

Although both Gnu Emacs and Xemacs come with HTML editing modes, another possibility is the excellent HTML-Helper-Mode by Nelson Minar. This mode, available from http://www.santafe.edu/~nelson/, is quick, has good syntax highlighting, and supports Netscape tags and tables.

Ben Wing, one of the main developers of Xemacs, has written an elaborate SGML editing mode, which could be useful to anyone writing in the Linuxdoc SGML format, as used by the Linux Documentation Project. This package is included with Xemacs.

The VM mail system is included with Xemacs, and can be obtained separately for use with Gnu Emacs. Though Rmail (the original Emacs mail client) comes with both Emacs versions, it’s not as full-featured as VM and uses a proprietary message format, which is a nuisance if you wish to access mail folders with other mail programs.

And then there is William Perry’s W3, an ongoing project (consisting of a package of LISP files) which allows Emacs to function as a web browser. In its latest incarnation W3 supports style-sheets, inline images, background colors and bitmaps, and even some of the Netscape tags. It’s written in LISP, though, and tends to be rather slow. With graphics turned off, running it is like running an improved Lynx as part of Emacs. W3 is definitely worth checking up on from time to time, as development is active and newer versions of Xemacs are likely to be optimized for running W3 as well. The current stable and beta versions of W3 can be obtained from ftp://ftp.cs.indiana.edu in the /pub/eLISP/w3 directory.

Conclusion

Either one of these two editors contains more features and obscure functions than most of us will ever use. Xemacs is characterised by its bells and whistles, and its developers maintain a strong presence on the Internet. Gnu Emacs may have more users, many of whom are also willing to help newcomers, but if you are interested in influencing future development of either editor, you will probably have more luck with the Xemacs team. Luckily the basic editing commands in each version are nearly identical, so if you learn one it doesn’t take long to come up to speed in the other.

Larry Ayers (layers@vax2.rain.gen.mo.us), lives on a small farm in northern Missouri, where he is currently engaged in building a timber-frame house for his family. He operates a portable band-saw mill, does general woodworking, plays the fiddle and searches for rare prairie plants, as well as growing shiitake mushrooms. He is also struggling with configuring a Usenet news server for his local ISP. His e-mail address is layers@vax2.rain.gen.mo.us.

x

Check Also

linux network monitoring

Introduction to Multi-Threaded Programming

Brian Masney Issue #61, May 1999 A description of POSIX thread basics for C programmers. ...