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

6.8.2.1 Example

6.8.2.1 Example

Let's say that you write a macro that copies comments from a program to another buffer. The comments in our program are preceded by a slash, so you start the macro with a search for a slash. However, not all comments are worth copying. Following the search with a query lets you decide case by case whether the search has found a comment you want to copy. Table 6-4 shows a macro to copy comments to another buffer.

Table 6-4. Comment-copying macro with a query

Keystrokes Action
F3 Start the macro definition.
C-s / Search for a slash.
Enter Stop the search when it is successful.
C-x q Insert a query in the macro; Emacs asks you if you want to proceed at this point when you run the macro.
M-f Move forward one word.
M-b Move to the beginning of this word.
C-Space Set the mark.
C-e Move to the end of the line.
C-f Move forward one character.
M-w Copy the comment to the kill ring.
C-x b comments Move to a buffer called comments.
C-y Insert the comment in the buffer.
C-x b Move back to the original buffer.
F4 End the macro definition.

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

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

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