Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [364]

By Root 1490 0
are special characters in regular expressions. Brackets are used to mark whole classes of characters you want to search for, such as [a-z] to represent "any lowercase character." We don't want the bracket before gyro to have this special meaning, so we put a backslash in front of it; this is called escaping the bracket. (In other words, we let the bracket escape being considered a metacharacter in the regular expression.)

The first asterisk in our expression follows a space, so it means "match any number of spaces in succession." The second asterisk follows the [a-z] character class, so it applies to that entire construct. By itself, [a-z] matches one and only one lowercase letter. Together, [a-z]* means "match any number of lowercase letters in succession."

A sophisticated use of regular expressions can take weeks to learn, and readers who want to base applications on regular expressions would do well to read Mastering Regular Expressions, by Jeffrey Friedl (O'Reilly).

Emacs and the X Window System

So far, we have only talked about Emacs as it could be run both in an X window and from a console. Now we will take a look at the X support that Emacs has.

The X features in Emacs are getting spiffier and spiffier. They include pull-down menus, different typefaces for different parts of your window, and a complete integration of cut-and-paste functions with the X environment. Most of the concepts here are mainly for the Emacs editor, as the XEmacs editor has built-in menus for many of the things described here. Nevertheless, many of the configurations described in this section work on both versions of Emacs.

Let's start by defining some nice colors for different parts of the Emacs window. Try this command:

eggplant$ emacs -bg ivory -fg slateblue -ms orangered -cr brown

You're setting the background color, foreground color, mouse color, and cursor color, respectively. The cursor is the little rectangle that appears in the window, representing what's called "point" in Emacs—the place where you type in text. We'll return to colors soon.

When you start Emacs, the menu bar on top and the scrollbar on the right side of the window stand out. See Figure 19-27.

Figure 19-27. Emacs window

The scrollbar works just like the xterm scrollbar. The menu bar offers a lot of common functions. Some editing modes, such as C and TEX, have their own pull-down menus. The menus are not documented, so you will just have to experiment and try to figure out to which Emacs functions they correspond.

When you want to use a function that doesn't have a simple key sequence—or you've forgotten the sequence—the menus come in handy. For instance, if you rarely use a regular expression search (a quite powerful feature, well worth studying), the easiest way to invoke it is to pull down the Edit menu and choose Regexp Search.

Another useful menu item is Choose Next Paste (Select and Paste on some versions) on the Edit menu. This offers something you can't get any other way: a list of all the pieces of text you've cut recently. In other words, it shows you the kill ring . You can choose the text you want to paste in next, and the next time you press C-y, it's put into your buffer.

If you get tired of the scrollbar and the menu, put the following LISP code in your .emacs file to make them go away:

(if (getenv "DISPLAY")

(progn (menu-bar-mode -1)

(scroll-bar-mode -1))

)

The mouse is the next X feature with interesting possibilities. You can cut and paste text much the same way as in xterm. And you can do this between windows: if you see some output in an xterm window that you'd like to put in a file, you can copy it from the xterm and paste it into your Emacs buffer. Moreover, any text you cut the normal way (such as through C-w) goes into the same selection as text you cut with the mouse. So you can cut a few words from your Emacs buffer and paste them into an xterm window.

The right mouse button works a little unusually. If you select text with the left mouse button, you can click once on the right mouse button to copy it. A

Return Main Page Previous Page Next Page

®Online Book Reader