Item 8: Learn the most important help functions
条款8:掌握最重要的帮助功能
To find out all the keyboard shortcuts that are defined for the current buffer, type M-x describe-bindings. It shows you a list of keys and the commands that they're mapped to.
要找出当前buffer中所有的按键功能,输入M-x describe-bindings。它显示一个包含按键及被绑定命令的列表。
If you move the cursor to one of the commands in this list, and hit Enter, it'll show you the Help for that command.
你把光标移动到相应的命令上,按回车,emacs会显示那个命令的帮助。
To find out what a particular key does, use M-x describe-key, and then type the key sequence you're interested in. It goes directly to the Help for that key, if the key is currently bound to a command.
想知道一个按键操作是干什么的,使用M-x describe-key,然后按入你感兴趣的按键序列。如果你输的序列是有绑定的,emacs会直接转到那个按键的帮助信息中。
If you're interested in finding a command, and you have a guess as to the name but you aren't sure exactly what it's called, use M-x apropos, followed by a regular expression (see Item 9) to use for matching command names. All Emacs commands (as well as functions variables, and property lists) are kept in global tables that can be searched with M-x apropos.
如果你对某个功能感兴趣,想找出相应的命令,并且你已经心里有个大约的命令名,那么你可以用M-x apropos,然后再输入一个正则表达式(参见条款9)来搜索命令名。所以的emacs命令(也包括函数和属性表)都存在一个全局表中,以备M-x apropos检索。
If, for instance, you're looking for a function that sends a buffer all the way to the back of the list, you could type M-x apropos-command buffer, which shows about 200 available commands with the word "buffer" in the command name. Near the top is a command, bury-buffer, whose documentation says:
bury-buffer M-x bury-buffer RET Command: Put BUFFER at the end of the list of all buffers.
比如:你想找一个功能,可以把一个buffer放到buffer列表的最末端,你就可以用M-x apropos-command,再输入“buffer”,就显示出所有200来个包含有buffer这词的命令。在这个列表里面靠前的有一个命令,bury-buffer,它的文档写道:
bury-buffer M-x bury-buffer RET Command: Put BUFFER at the end of the list of all buffers.
Et voila. Just the command you were looking for. You can easily winnow the search through large lists by specifying a more restrictive regexp.
瞧!这不就是你要找的吗?用好(regexp)正则表达式的话,你很容易就可以限定搜索显示的范围。
Perhaps the most important Help function is M-x info, which brings up Emacs's interactive,menu-driven Info engine. You should learn to use Info. It has thousands of pages of documentation,and it's hyperlinked (in its own custom way that predates the Web, unfortunately), so it's much easier to navigate than, say, man pages. Once you've mastered the navigation keys in Info, it's faster than navigating HTML help with a browser, even for local static files, in part because of Info's ability to perform searches across multiple info files, and in part because Emacs simply has better navigation capabilities than any web browser.
要说最最重要的emacs帮助命令,当属M-x info,这命令会开启emacs内置的交互式,菜单驱动的Info引擎。你应该学学怎么用Info。它包含数千页的文档,而且是超文本链接的(很不巧,是web出现之前的emacs自有链接风格),所以比man页要易读得多。一旦你掌握了Info系统的导航键,用起来铁定比用浏览器看HTML帮助要快,即便是看本地文件也是如此。一方面,是因为emacs info有跨info文件搜索的功能,另一方面,就只归功于emacs有相比于浏览器更好的文本导航能力。