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

14.2.2 Apropos Commands

14.2.2 Apropos Commands

Another type of help command applies when you want Emacs to do something, but you're not sure exactly what command to use or what variable to set. These are apropos commands, which resemble a rudimentary information retrieval system of the type found at many libraries. The apropos command has several forms, shown in Table 14-2.

Table 14-2. Apropos commands

Keystrokes Command name Question answered
C-h a Help ? Search Documentation ? Find Commands by Name apropos-command What commands include this word?
(none) Help ? Search Documentation ? Find Options by Name apropos-variable What variables include this regular expression?
(none) Help ? Search Documentation ? Find Options by Value apropos-value What variables are set to this regular expression?
(none) Help ? Search Documentation ? Search Documentation Strings apropos-documentation Where is this regular expression mentioned in the documentation?
(none) Help ? Search Documentation ? Find Any Object by Name apropos What functions and variables involve this regular expression?

All apropos commands prompt for regular expressions (an ordinary text string will work, but you can create more powerful searches using regular expressions; see Chapter 11 for details). When you type C-h a followed by a regular expression, Emacs finds all the commands that match it; it displays their key bindings (if any) and the first lines of their documentation in an *Apropos* window that is in Apropos mode. This mode displays hyperlinked help. If you click on a bolded item using your middle mouse button or move the cursor there and press Enter, Emacs displays more information.

As always, if you are leery of using regular expressions, use regular search strings as long as you stick to nonspecial characters. For example, if you want to know what replace commands Emacs supports, press C-h a and then type replace; Emacs displays a list of information on the following commands:

• dired-do-query-replace

• ebrowse-tags-query-replace

• ethio-replace-space

• map-query-replace-regexp

• query-replace

• query-replace-regexp

• query-replace-regexp-eval

• replace-buffer-in-windows

• replace-rectangle

• replace-regexp

• replace-string

• tags-query-replace

If you have ever used an information retrieval system, you already know that some skill is needed to use such a system effectively. You need to choose your concepts (search strings) carefully, so that they aren't too general (too much output to wade through) or too specific (too little output, making it less likely that you get the information you want). This problem is compounded when you use the apropos command, which is the same as apropos-command except that it reports on all functions (including internal Emacs functions) and variables as well as commands.

If you type in a search string that is too general, Emacs produces an enormous buffer of help information. For example, invoking apropos-command with the argument "buffer" results in output listing well over two hundred Emacs commands. In general, you may have to invoke the apropos commands a few times to get the information you want (in terms of size as well as relevance).

The apropos command itself is usually overkill, unless you are a Lisp programmer who needs information on noncommand functions (see Chapter 11 for details on this use of apropos). Use a more specific command when possible. For example, to get information on variables, use apropos-variable. To find out about variables related to auto-saving, type M-x apropos-variable Enter auto-save Enter. Emacs responds with information about the variables auto-save-default, auto-save-file-format, auto-save-file-name-transforms, auto-save-interval, auto-save-list-file-prefix, auto-save-timeout, auto-save-visited-file-name, and delete-auto-save-files. To find the value and full description of one of these variables, move to the *Apropos* window and either click with the middle mouse button or move to the desired variable and press Enter.

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

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

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