Debra Cameron - Learning GNU Emacs, 3rd Edition

Здесь есть возможность читать онлайн «Debra Cameron - Learning GNU Emacs, 3rd Edition» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Год выпуска: 2004, ISBN: 2004, Издательство: O'Reilly Media, Жанр: Программы, Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Learning GNU Emacs, 3rd Edition: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Learning GNU Emacs, 3rd Edition»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

GNU Emacs is the most popular and widespread of the Emacs family of editors. It is also the most powerful and flexible. Unlike all other text editors, GNU Emacs is a complete working environment—you can stay within Emacs all day without leaving.
, 3rd Edition tells readers how to get started with the GNU Emacs editor. It is a thorough guide that will also "grow" with you: as you become more proficient, this book will help you learn how to use Emacs more effectively. It takes you from basic Emacs usage (simple text editing) to moderately complicated customization and programming.The third edition of
describes Emacs 21.3 from the ground up, including new user interface features such as an icon-based toolbar and an interactive interface to Emacs customization. A new chapter details how to install and run Emacs on Mac OS X, Windows, and Linux, including tips for using Emacs effectively on those platforms.
, third edition, covers:
• How to edit files with Emacs
• Using the operating system shell through Emacs
• How to use multiple buffers, windows, and frames
• Customizing Emacs interactively and through startup files
• Writing macros to circumvent repetitious tasks
• Emacs as a programming environment for Java, C++, and Perl, among others
• Using Emacs as an integrated development environment (IDE)
• Integrating Emacs with CVS, Subversion and other change control systems for projects with multiple developers
• Writing HTML, XHTML, and XML with Emacs
• The basics of Emacs Lisp
The book is aimed at new Emacs users, whether or not they are programmers. Also useful for readers switching from other Emacs implementations to GNU Emacs.

Learning GNU Emacs, 3rd Edition — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Learning GNU Emacs, 3rd Edition», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

It is often a good idea to add extra commands (typically C-aand C-e) that aren't strictly necessary, just to make sure that you're positioned correctly on the line. The fewer assumptions that a macro makes, the better it works. So, if a sequence of commands works correctly only if you start at the end of the line, start the macro with C-e, even if you already "know" that you want to give the command only when you're at the end of the line.

Finally, while we're reciting rules and cautions, here's one more: keep in mind that you probably want to execute macros repeatedly. With a little foresight, you'll be able to create macros that can be executed in long chains without problems.

In general, good macros have three parts:

• They find the place you want the macro to start working (often using search).

• They do the work that needs to be done on the text.

• They prepare themselves to repeat.

How can a macro prepare itself to repeat? For example, assume that you're writing a macro to delete the third column of a table. After deleting the column, the macro should position itself at the beginning of the next line (or wherever it needs to be) so you don't have to reposition the cursor before reusing it.

Here's a slightly more complex example. If you start a macro with a search, you have to make sure that the end of the macro moves the cursor past the last spot you searched for. If you don't, the macro will keep finding the same place in the file and never go on to the next occurrence of what you're searching for. As a general rule, if your macro operates on a line of text, it should end by moving to the beginning of the next line. Remember that your goal is to create a sequence of keystrokes that can be executed many times in a row, with no interruption.

6.3 A More Complicated Macro Example

Sometimes you may want to find all the references to a particular topic in a file. Table 6-2lists steps for creating a macro that takes takes every sentence in the buffer that contains the word Emacs and copies it to another buffer. If you try this macro, you'll need to type some text about Emacs into a buffer. You can also get a test file to work with by opening the Emacs NEWS file (using C-h n), then writing it to a file ( C-x C-w NEWS). This buffer is in view mode by default; change to text mode by typing M-x text-mode Enter.

Table 6-2. Steps for macro that creates a buffer of Emacs references

Keystrokes Action
F3 or C-x ( Start macro definition; Defappears on the mode line.
C-s emacs Find the word Emacs.
Enter Stop the search after it is successful; if the search is unsuccessful, it rings the bell and stops the macro.
M-a Move to the beginning of the sentence. [34]
C-Space Set the mark.
M-e Move to the end of the sentence.
M-w Copy the sentence to the kill ring.
C-x b emacsrefs Enter Move to a buffer called emacsrefs.
C-y Insert the sentence.
Enter Start the next sentence on a new line.
C-x b Enter Move back to the original buffer.
F4 or C-x ) End the macro definition; Defis removed from the mode line.

Now, assume that you've already constructed the macro outlined in Table 6-2and that you can invoke it with F4. The following screen shows what happens when you run it five times and then display the emacsrefsbuffer.

Type: M-5 F4or M-5 C-x e, followed by C-x b Enter

By executing the macro repeatedly weve created a buffer that contains - фото 99

By executing the macro repeatedly, we've created a buffer that contains references to the Emacs editor.

As in the previous example, you can jump back and forth between an unlimited number of buffers while defining a macro. Macros don't need to be confined to one buffer. Macros that work with several buffers are more difficult to debug; when several buffers are involved, it becomes harder for you to keep track of where the cursor and the mark are. It is also easy to make mistaken assumptions about what buffer you're visiting; hence, it's a good idea to specify the buffer name explicitly. However, after you get accustomed to working with macros and multiple buffers, you'll be amazed at how much work you can do with almost no effort.

Windows are sometimes useful in macros, but, again, you have to watch out. It's better to start a macro with one window on the screen, have the macro open other windows, and finally close all but one window ( C-x 1). If you write a macro with two windows on the screen and later try to execute it with four windows on the screen, the results will be unpredictable at best! In general, moving to a named buffer, C-x b buffername , is preferable to moving to the "other" window using C-x o(too vague to be generally useful). The other window could be anything—a *Help*buffer, *Completion*buffer, *shell*buffer, and so on. Moving to a named buffer always gets you to the right place, no matter how (or whether) the buffer is displayed.

6.4 Editing a Macro

You can edit a macro and make changes to it in a few different ways. For this example, we chose an all-purpose editing command, edit-kbd-macro, which is bound to C-x C-k e. Several macro editing commands are available, but this one works for all types of macros, so it's good to learn.

Our macro could use a bit of tweaking. First of all, finding references to Emacs in our copy of the Emacs NEWS file is pretty lame. Perhaps we're interested in using a mouse more frequently with Emacs and would like to know about changes to that part of the interface. We'll edit the macro to search for the word mouse . We'll also modify it so it marks a paragraph rather than a sentence since a sentence doesn't really provide enough context to be helpful.

Let's start editing the macro.

Type: C-x C-k e

Emacs prompts you for the type of macro to edit Emacs asks you if you want to - фото 100

Emacs prompts you for the type of macro to edit.

Emacs asks you if you want to edit the last keyboard macro ( C-x e), a named macro ( M-x), the last 100 keystrokes as a macro, termed "lossage" ( C-h l), or keys (meaning the keystrokes you bound a macro to). Yes, that's a lot of choices, and later in the chapter we describe named macros and binding macros to keys (you can experiment on your own with creating a macro from lossage). For now, just choose C-x eto edit the last keyboard macro.

Type: C-x e

Emacs opens an Edit Macrobuffer Notice two fields near the top of this - фото 101

Emacs opens an *Edit Macro*buffer.

Notice two fields near the top of this buffer, Command:and Key:. Right now, Command:says last-kbd-macro. If this were a named macro, the command would be the name you gave your macro. Additionally, for frequent use, you can bind your macro to a key, at which point the Key:field lists the keystrokes to execute this macro. Right now it says nonebecause we haven't defined any keystrokes yet.

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Learning GNU Emacs, 3rd Edition»

Представляем Вашему вниманию похожие книги на «Learning GNU Emacs, 3rd Edition» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Learning GNU Emacs, 3rd Edition»

Обсуждение, отзывы о книге «Learning GNU Emacs, 3rd Edition» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x