Книга: Learning GNU Emacs, 3rd Edition

6.8.1.1 Example

6.8.1.1 Example

Here's an example of a macro that puts a business letter template on the screen and uses recursive edits to let you type your return address, the recipient's name and address, and the date. Because the brackets on the mode line are a pretty subtle clue to what you are going to type, we'll give the user of this macro explicit instructions about what to type. Table 6-3 provides these instructions.

Table 6-3. Steps for creating a business letter macro

Keystrokes Action
F3 orC-x ( Start keyboard macro definition.
M-5 Enter Put in 5 blank lines.
Type your address and press C-M-c Display Type your address and press C-M-c on the screen.
C-a Move to the beginning of the line.
C-u C-x q Enter a recursive edit, during which the keystrokes you type are not recorded as part of the macro.
C-M-c Exit the recursive edit.
C-e Move to the end of the line.
M-5 Enter Move the cursor down 5 lines.
Type recipient name and address and press C-M-c Display Type recipient name and address and press C-M-c on the screen.
C-a Move to the beginning of the line.
C-u C-x q Enter a recursive edit.
C-M-c Exit the recursive edit.
C-e Move to the end of the line.
M-5 Enter Move the cursor down 5 lines.
Type date and press C-M-c Display Type date and press C-M-c on the screen.
C-a Move to the beginning of the line.
C-u C-x q Enter a recursive edit.
C-M-c Exit the recursive edit.
C-e Move to the end of the line.
M-5 Enter Move the cursor down 5 lines.
Dear Space Display Dear on the screen.
F4 orC-x ) End keyboard macro definition.

The following screens show what the macro defined in Table 6-3 looks like when you run it.

Type: F4


The macro pauses so that you can type your address.

Type your address and press: C-M-c


The macro pauses so you can type the recipient's name and address.

Type the recipient's name and address and press: C-M-c


The macro pauses so you can type the date.

Type the date and press: C-M-c


The macro finishes by typing the opening for the letter.

Now the macro has finished editing; you can type the recipient's name and then the body of the letter, and of course you can go back and edit any of the information you've already filled in.

Оглавление книги

Оглавление статьи/книги

Генерация: 0.083. Запросов К БД/Cache: 0 / 2
поделиться
Вверх Вниз