O'Reilly logo

Learning GNU Emacs, 3rd Edition by Bill Rosenblatt, Eric S. Raymond, Marc Loy, James Elliott, Debra Cameron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

About the Emacs Display

When you enter Emacs, you see a large workspace near the top of the window where you do your editing. (See Figure 1-1.)

Understanding the Emacs display

Figure 1-1. Understanding the Emacs display

A cursor marks your position. The cursor is also called point, particularly among people who are more familiar with Emacs and in the online help system; therefore, it's useful to remember this term.

You don't have to do anything special before you start typing. As long as you type alphanumeric characters and punctuation, Emacs inserts them into your buffer. The cursor indicates where Emacs inserts the new characters; it moves as you type. Unlike many editors (particularly vi), Emacs does not have separate modes for inserting text and giving commands. Try typing something right now, and you'll begin to see how easy Emacs is to use. (If you get stuck for any reason, just press C-g.)

The Toolbar

The toolbar is a new feature in Emacs 21. Its basic icons and their functions are listed in Table 1-3. Note that the toolbar is context sensitive; in some modes, such as the Info mode for reading the Emacs manual, the toolbar changes to provide browsing help. We'll discuss those icons when we cover the relevant modes.

Table 1-3. Icons on the Emacs toolbar

Icon

Function

Where to learn more

image with no caption

Find a file or create a new file (supplying the filename).

This chapter

image with no caption

Start the directory editor so you can manipulate files and folder.

Chapter 5

image with no caption

Kill the current buffer.

Chapter 4

image with no caption

Save current buffer in its associated file.

This chapter

image with no caption

Save current buffer as a different file.

This chapter

image with no caption

Undo.

Chapter 2

image with no caption

Cut text that comprises the current region.

Chapter 2

image with no caption

Copy text in current region.

Chapter 2

image with no caption

Paste cut or copied text.

Chapter 2

image with no caption

Search for a string.

Chapter 3

image with no caption

Print page (with headings).

Chapter 5

image with no caption

Customize using interactive interface.

Chapter 10

image with no caption

Start online help system.

Chapter 14

If you don't like the toolbar, you can hide it using a menu option (Options Show/Hide Toolbar), and choosing Options Save Options. For more information, see Section 2.7 at the end of Chapter 2.

The Menus

The menu bar menu lists the options File, Edit, Options, Buffers, Tools, and Help; you can explore them to see what options are available.

In addition to navigating the menus using the mouse, Emacs now offers pop-up menus. In the Emacs window, hold down Ctrl and click the right mouse button to pop up the Edit menu.[2]

You can access menus without a mouse using the keyboard. In this case, using keyboard commands is much more efficient than menus, but for completeness, we'll show you how to use the text-based menus. (If you prefer to use the mouse with Emacs but have access only to a text interface, see Chapter 13 to learn how to download and install a version of Emacs that runs graphically on Unix, Linux, Mac OS X, or Windows.)

If your mouse does not work with the menus, press F10 or M-` (a back quote, the single open quotation mark, located above the Tab key in the upper-left corner of many keyboards) to access them.

Press: F10

image with no caption

Using text-based menus (Emacs 21.2 on Mac OS X Terminal application).

You can select text-based menu options in three ways:

  • You can press Enter to select the default option that appears in the minibuffer. If you want a different one, press the up or down arrow key until the option you want appears and press Enter.

  • You can type the letter preceding the option in the *Completions* buffer. For example, type f to choose File.

  • You can press PgUp to move to the *Completions* buffer, then use the arrow keys to move to the option you want. Press Enter. (On Mac OS X, press Shift-PgUp instead.)

After you select a menu option, choices for that menu appear. Repeat the process until you find the option you're looking for.

The Mode Line

Just above the bottom of the window (on the second-to-last line), Emacs prints a lot of information about what it's doing. This line is called the mode line. At the beginning of the mode line, you may see some information about the coding system that Emacs is using for the file; usually you'll see just --:, indicating that there is no unusual encoding scheme in place. Near the left edge of the mode line, you may see two asterisks (**). These asterisks indicate that you've modified whatever you're editing. If you haven't made any changes, the asterisks won't be there. Next, Emacs prints the name of the buffer you are editing (*scratch*). Following this, Emacs shows where you are in the buffer—your position relative to the rest of the file and what line you are on (L5 for line 5 in Figure 1-1). If you're at the beginning of the file, Emacs prints the word Top; if you're at the end, it prints Bot; if you're in the middle, it shows you a percentage (for example, 50% means you're looking at the midpoint); and if the entire file is visible, Emacs prints the word All. In parentheses following this is the editing mode or modes you are in, in this case Lisp Interaction is the major mode (no minor modes are active). The scrollbar on the side of the window also indicates your position in the file.[3]

You will often work with several buffers simultaneously. In this case, each buffer has its own mode line, and when you switch buffers, the mode line reflects the state of the current buffer. Don't worry about this for now; just remember that every buffer has a mode line to describe it.

The Minibuffer

Below the mode line is the minibuffer. This is the area where Emacs echoes the commands you enter and where you specify filenames for Emacs to find, values for search and replace, and so on. It is also where Emacs displays error messages. If you find yourself stuck in the minibuffer, press C-g to get out again.



[2] Emacs works best with a three-button mouse (more buttons are okay, too).

[3] The scrollbar's location depends on the platform and windowing system you're using. Linux puts scrollbars on the left while Mac OS X and Windows put them on the right by default. Note also that the order of the information in the mode line is different if you run Emacs in a terminal window.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required