Выбрать главу

Cut text that comprises the current region.

Chapter 2

Copy text in current region.

Chapter 2

Paste cut or copied text.

Chapter 2

Search for a string.

Chapter 3

Print page (with headings).

Chapter 5

Customize using interactive interface.

Chapter 10

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.

1.5.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.[6]

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

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.

1.5.3 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.[7]

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.

1.5.4 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.

1.6 Emacs Commands

You're about to start learning some Emacs commands, so let's discuss them a bit first. How do you give commands? Each command has a formal name, which (if you're fastidious) is the name of a Lisp routine. Some command names are quite long; you usually wouldn't want to type the whole thing. As a result, we need some way to abbreviate commands.

Emacs ties a command name to a short sequence of keystrokes. This tying of commands to keystrokes is known as binding. Even things you don't normally think about as commands, such as inserting the characters that you type, are handled through the binding mechanism. Keys like "A" are bound to the Emacs command self-insert-command, which inserts them into the buffer you are editing.[8] Most actions that you would normally think of as editor commands are bound to keystroke sequences starting with Ctrl or Meta. Emacs also binds some commands to mouse clicks (alone or modified by Shift or Ctrl) and to options on menus.

The authors of Emacs try to bind the most frequently used commands to the key sequences that are the easiest to reach. Here are the varieties of key sequences you'll encounter:

• The most commonly used commands (such as cursor movement commands) are bound to C-n (where n is any character). To press C-n, press and hold the Ctrl key and press n, then release both keys.

• Slightly less commonly used commands are bound to M-n. To press M-n, press and hold the Meta key (usually next to the space bar), then press n.

• Other commonly used commands are bound to C-x something (C-x followed by something else—one or more characters or another control sequence). Among other types of commands, file manipulation commands, like the ones you are about to learn, are generally bound to C-x something.

• Some specialized commands are bound to C-c something. These commands often relate to one of the more specialized modes, such as Java mode or HTML mode. You won't encounter them until later in this book.

вернуться

6

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

вернуться

7

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.

вернуться

8

In certain special editing modes, such as dired-mode for viewing and manipulating directories on your computer, the normal typing keys don't insert themselves. They are instead bound to special commands that do things like opening and renaming files. This flexibility in defining and changing keymaps, while it might seem somewhat arbitrary and overwhelming at first, is one of the great sources of power in Emacs.