EMACS IS the kitchen sink!- by Murray Todd Williams

For those of you just tuning in...

This article is the third part of a series on GNU software for OS/2. The original article describes GNU: a vast collection of free software written for a variety of platforms (operating systems and microprocessors) by some incredible programmers. In essence, the GNU system turns your OS/2 machine into an OS/2 - Unix hybrid, giving you the best of both worlds!

The second article gave instructions for installing the basic components of GNU, as well as a powerful C/C++ compiler. It also gave a sneak-preview of the XFree86 for OS/2 project. (In a few words, XFree86 for OS/2 is a freeware version of X-windows client and server.)

This article will introduce EMACS for OS/2. This is no small feat! As you will soon see, EMACS is more like a small, encapsulated operating system than a text editor. It is impossible for me to show you everything EMACS can do, but I can at least point you in the right direction!

But first, more news from the beta field!!

When I wrote last month's article, XFree86 was still considered Alpha-level code. There were a few glitches and installation required some real work. As of last week, the next beta version was released. I've already installed it and the few problems that I had encountered are fixed. For more information, look at the XFree86/OS2 project homepage.

Even more spectacular, I learned today that the newest EMACS Version 19.31 for OS/2 has been completed, and it is enabled for X-windows. This represents the most powerful program ported to XFree86 for OS/2 to date! Now you can run EMACS as a PM program or an X-windows program.

And now, Introducing EMACS...

On every UNIX system, you are likely to find two standard text editors. The first is called vi. This little program is analogous to EDLIN in the DOS world: small, ubiquitous, but a royal pain to use. The second is EMACS.

Yes, EMACS is a text-editor. It's important to note that EMACS is not a WYSIWYG word processor. If you need a word processor, use DeScribe or Word Pro. If your need for a text editor is limited to occasionally editing a line in CONFIG.SYS, then perhaps EMACS is not for you. (Next month I'll introduce a very nice "word processor" called TeX which can be integrated into EMACS.) If your needs fall in between, EMACS may be the answer.

What has it got?

EMACS is a complete PM application (GIF, 14k) (and now it's also an X-windows application!) with pull-down menus. It has a variety of major modes which correspond to the files your are working with. For example, if you load a C++ program, EMACS automatically detects that the file is C++ source code and loads a specific "C++ Mode". This mode sets tabulation behavior, color-codes the text (comments are in red, compiler directives are green, etc.) and even can run the compiler, display resulting errors, or run the program.

Similarly, if I load a TeX (that text formatting application I mentioned earlier) document it will automatically enter TeX Mode and with a single keystroke all of my work gets color-coded. Another two keystrokes and I'm running the file through the TeX processor. Two more keystrokes and I'm launching a graphical viewing program to inspect the document. Another two keys start a print job. (If I install the GNU program Ispell, I can even run the document through a spell-checker.)

You're not impressed yet? What if you could check your e-mail with the same text editor? EMACS can even browse USENET news groups and run a text-based WWW browser!

What's their secret?

How can anyone write a do-it-all text editor without bogging it down with unimportant features until it's top-heavy, slow, and awkward (some popular Windows word processors come to mind)? The secret is inspired, but a little insane.

Here's the trick: most of EMACS internal operations are done in LISP! If you haven't heard of LISP before, it was one of the first languages associated with Artificial Intelligence. LISP is guaranteed to twist your brain into Manicotti. I have infinite respect for anyone who can write a program in LISP. (I also tend to fear these people. Are they human?)

In terms of EMACS, this implementation has worked quite well. Almost all features are simply byte-compiled LISP programs, the source code for which is provided in the GNU distribution. If you wish to tweak, change or correct anything, just find the corresponding LISP file and have at it!

The beauty in this setup can also be seen in the portability of EMACS. If you go searching on the Web, you can find an HTML mode for writing HTML pages. This is effectively a "third-party" program written for EMACS. You won't find it in the OS/2 distribution, but with a small amount of effort (this usually involves stuffing a file in the \emacs\19.31\LISP directory and adding a couple lines to the site-start.el file) you can get it installed and running.

A couple more goodies.

I can't help bragging about a couple of the crazier features (LISP programs) in EMACS. Here are a couple of my favorites: Let me show you some output from the doctor program:
I am the psychotherapist.  Please, describe your problems.
Each time you are finished talking, type RET twice.

Doctor, I would like to introduce you to my readers.

How does it feel to want?

That's an odd question.  It feels normal.

Is it because of your life that you say it feels normal?

Doctor, that's a pretty existential question.

You mentioned that you would like to introduce?

Oh yes.  My audience.  They are here to learn about the
magic of EMACS.

Emacs?  Hah!  I would appreciate it if you would continue.

Well, did you know you are simply a utility written in
LISP?

Are you sure of that?

Oh, I hope I didn't hurt your feelings.

Is it because of your sex life that you say you hope you
didn't hurt my feelings?
Well, this is probably a good time to stop.

So how's the learning curve?

In a word: steep. Although there are pull-down menus, most of the features you want to use are connected to strange keystrokes. Of course, if you forget the keys to invoke a particular command, you can type out the full name. For example, to spell-check a single word you would type Alt-$. You could also type "Alt-x ispell-word". There is also an extensive help system to draw upon when you need to hunt for the right command.

Finally, there is a built-in tutorial which is sufficient to get you going. When you start EMACS each time, it displays a couple of options, including a tutorial (Ctrl-h t).

Customizing your setup.

Configuring and customizing EMACS for your own use is fairly easy. The only frightening aspect is that you are really writing LISP code. This shouldn't frighten you though. Most of the code is equivalent to writing "LET X=3" in basic. Just create a file called .emacs in your home directory (remember adding "SET HOME=" to your CONFIG.SYS when you set up GNU in last month's article?). Here is a simple example of a .emacs file:
(global-set-key [f7] 'font-lock-mode)
(global-set-key [f8] 'auto-fill-mode)
(require 'tex-site)
The first two lines set the function keys to the "font-lock-mode" (which color-codes your text) and "auto-fill-mode" (which activates word-wrap) commands. The third line tells EMACS to load the tex-site.el LISP file upon startup (this is basically loading a "third party" EMACS utility that I got from the web).

How do I get EMACS up and running?

I suggest you look are last month's article where I discussed the Hobbes FTP Archive. This is one of the best places to find GNU software. In the /os2/unix directory, you should find a number of directories for EMACS. You will want the latest version (19.30 or 19.31). Download the e30.readme file for more specific instructions. Despite its power and complexity, EMACS is not difficult to install (compared with GNU C++ or EmTeX).

Follow the instructions carefully and when you run EMACS for the first time, type "Alt-h t" to run the tutorial. Take maybe two or three hours (you might want to take notes) and work through the tutorial. By the time you are finished, you should be comfortable enough to forge ahead on your own.

I wish I could give a more complete description of EMACS, but it is simply too big for me to do justice. This is one of the most amazing programs available as Freeware for OS/2. Until you get up to speed on your own, you'll have to take my word for it.

Here are a few web links which might prove helpful:

Additionally, if you want to do your newsreading and e-mail from EMACS, you should check out GNUS: a Usenet newsreader and e-mail user agent implemented as a part of EMACS.

Stay tuned for next month's episode

Earlier in this article I mentioned TeX. This typesetting program permits the creation of very nicely formatted documents. You can keep track of references, bibliographies, tables of contents, indices and more. Perhaps more importantly, it is the standard for writing mathematical documents and typesetting equations. Next month I will introduce EmTeX (the GNU - OS/2 implementation of TeX), go through a more cautious description of its installation, and as an added treat, discuss finding and adding the AUCTeX module to EMACS. AUCTeX allows all the features of TeX to be run from within EMACS so you can compile, view and print from the same program.

Until then...


Murray Todd Williams is a student at Colorado State University, working on a M.S. in Statistics. He is also a member of Team OS/2.

[Index]  [® Previous] - [Feedback] - [Next ¯]
Our Sponsors: [J3 Comp. Tech.] [Mt. Baker] [Post Road Mailer] [ScheduPerformance]


This page is maintained by Falcon Networking. We welcome your suggestions.

Copyright © 1996 - Falcon Networking