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

14.2.1 Detail Information

14.2.1 Detail Information

Let's start with the help commands that are useful when you need to look up a specific detail. You'll probably use the commands listed in Table 14-1 most often.

Table 14-1. Detail information help commands

Keystrokes Command name Question answered
C-h c describe-key-briefly What command does this keystroke sequence run?
C-h k Help ? Describe ? Describe Key describe-key What command does this keystroke sequence run, and what does it do?
C-h f Help ? Describe ? Describe Function describe-function What does this function do?
C-h v Help ? Describe ? Describe Variable describe-variable What does this variable mean, and what is its value?
C-h m Help ? Describe ? Describe Buffer Modes describe-mode Tell me about the modes the current buffer is in.
C-h b Help ? Describe ? List Key Bindings describe-bindings What are all the key bindings for this buffer?
C-h w where-is What is the key binding for this command?
C-h s describe-syntax What is the syntax table for this buffer?
C-h l view-lossage What are the last 100 characters I typed?
C-h e view-echo-area-messages What messages have appeared in the minibuffer during this session?

What if you press the wrong key, and something happens to your buffer—but you're not sure what? Usually, the safest thing to do is to press C-_ or C-x u(undo). But sometimes this command won't help, for example, a runaway replace-string. If you remember what you typed, you can use C-h c (for describe-key-briefly) to see what command was run; just retype the offending keystroke(s) at the prompt, and Emacs responds with the name of the command bound to the key(s) in the minibuffer. If the command name alone doesn't help, C-h k (for describe-key) pops up a *Help* window with a description of the command as well as its name and key binding. (C-h k and C-h c also help you find out what command a toolbar icon or menu item runs.)

However, if you don't know what keys you pressed, you can type C-h l (for view-lossage). This pops up a *Help* window showing the last 100 keystrokes you typed; the offending ones are likely near the end, and you can use C-h c or C-h k with those keystrokes.

Now suppose you want information on a command that isn't bound to keystrokes. Type C-h f (for describe-function) and enter the name of the command at the prompt; Emacs responds with a *Help* window containing the documentation for that command. If you remember the name of a command but forget its binding, type C-h w (for where-is). This is the "opposite" of C-h c; it shows the key binding for a given command in the minibuffer, or the message command-name is not on any keys if the command has no binding.

You may forget a detail that involves the value of a variable. For example, will Emacs respect or ignore case during a search (the variable case-fold-search)? How often are my buffers being auto-saved (the variable auto-save-interval)? If you type C-h v (for describe-variable) followed by the name of the variable, Emacs puts its value as well as its documentation in a *Help* window. C-h f, C-h w, and C-h v all allow you to use completion when typing command or variable names. C-h f and C-h v are also especially useful to Emacs Lisp programmers; note that C-h f gives you information on all functions, not just those bound to keystrokes as commands.

Another common help situation arises when you use a special mode, such as shell mode or a mode for a programming language or text processor, and you forget a command specific to that mode or some other characteristic such as indentation conventions. If you type C-h m (for describe-mode) in a buffer running the mode, Emacs pops up a *Help* window showing the mode's documentation. Documentation for a mode usually includes all of its local key bindings (for example, all the commands special to the mode and their associated keystrokes), customization variables, and other interesting characteristics.

What if you want to find out all the keyboard commands available in a given mode? C-h b (for describe-bindings) gives you a *Help* window showing all key bindings active in the current buffer, including local (buffer-specific) as well as global ones. It also lists all bindings for mouse actions, menu options, and function keys.

C-h b produces quite a lot of output. If you want to limit this output to only those key bindings with a particular prefix, type that prefix followed by C-h. For example, typing C-x C-h produces a *Help* window listing all key bindings that begin with C-x.

C-h s (for describe-syntax) is a more specialized command, designed for Lisp programmers. It produces a *Help* window with a description of the syntax table (see Chapter 9) active in the current buffer.

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

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

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