32
Emacs editing environment, Part 7: Let Emacs help you out Get editing assistance right from the editor Skill Level: Intermediate Michael Stutz ([email protected]) Author Consultant 13 Nov 2007 Part 7 of this series shows you why Emacs is the self-documenting editor, and the many ways in which you can take advantage of the help and assistance offered in this editor. In this tutorial, learn about describing keystrokes, commands, and functions. You'll also read, browse, and search through a complete Emacs reference manual. Section 1. Before you start Learn what to expect from this tutorial, and how to get the most out of it. About this series The Emacs editing environment is a favorite of UNIX® developers. It's known around the world as the king of editors, but many users find it has a bit of a learning curve. The Emacs environment doesn't seem intuitive at first glance, and it doesn't work like other editors and word processors. But learning Emacs doesn't have to be difficult. Once you get going, you'll see how intuitive it is and become more comfortable with it after each use. This tutorial series (see Resources) shows you the way, taking you from the basics of Emacs, such as its features, philosophy, key-command layout, and methods for editing text, through many of its powerful editing features. After completing this series (see Resources), you'll be able to comfortably use Emacs for everyday editing, be well on your way to Emacs proficiency, and have a Let Emacs help you out © Copyright IBM Corporation 1994, 2008. All rights reserved. Page 1 of 32

Emacs editing environment, Part 7: Let Emacs help you out · the first tutorial in this series (see Resources) that the C-x C-ccombination is the usual command to exit Emacs: As the

  • Upload
    trannhu

  • View
    226

  • Download
    0

Embed Size (px)

Citation preview

Emacs editing environment, Part 7: Let Emacshelp you outGet editing assistance right from the editor

Skill Level: Intermediate

Michael Stutz ([email protected])AuthorConsultant

13 Nov 2007

Part 7 of this series shows you why Emacs is the self-documenting editor, and themany ways in which you can take advantage of the help and assistance offered inthis editor. In this tutorial, learn about describing keystrokes, commands, andfunctions. You'll also read, browse, and search through a complete Emacs referencemanual.

Section 1. Before you start

Learn what to expect from this tutorial, and how to get the most out of it.

About this series

The Emacs editing environment is a favorite of UNIX® developers. It's known aroundthe world as the king of editors, but many users find it has a bit of a learning curve.The Emacs environment doesn't seem intuitive at first glance, and it doesn't worklike other editors and word processors. But learning Emacs doesn't have to bedifficult. Once you get going, you'll see how intuitive it is and become morecomfortable with it after each use. This tutorial series (see Resources) shows youthe way, taking you from the basics of Emacs, such as its features, philosophy,key-command layout, and methods for editing text, through many of its powerfulediting features.

After completing this series (see Resources), you'll be able to comfortably useEmacs for everyday editing, be well on your way to Emacs proficiency, and have a

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 1 of 32

good feel for many of the advanced capabilities of Emacs.

About this tutorial

This is the seventh in a series of tutorials on learning Emacs (see Resources).Previous tutorials in this series took you through the basics; this intermediate-level,hands-on tutorial builds on what you learned in the early tutorials, and shows thosealready familiar with the rudimentary controls of Emacs how to obtain assistancefrom Emacs using the many built-in help features.

Emacs is called the self-documenting editor, because assistance is available fromthe application for every keystroke or action you make. From describing keystrokes,commands, and functions you give it to reading and browsing the manydocumentation files and a complete reference manual, you learn all the best ways toget instant help from the Emacs editor.

Objectives

This tutorial shows you how to obtain help from Emacs in various ways. Afterworking through this tutorial, you'll know how to get descriptions of keystrokes,commands, functions, and read and browse through the many documentationresources that come with this world-famous open source editor.

Prerequisites

Before working through this tutorial, you should complete the previous tutorials inthis series. They lay down the basic foundation, and explain many of the Emacsconcepts you use in this tutorial (see Resources).

The special Emacs notation for representing keystrokes, which is used in this tutorialand throughout the series, is described in the introduction of the first tutorial of theseries, "Learning the Emacs editing environment, Part 1: The basics of Emacs" (seeResources).

Although this tutorial is written for all levels of UNIX expertise, it's helpful if you haveat least a rudimentary understanding of the UNIX file system:

• Files

• Directories

• Permissions

• File system hierarchy

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 2 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

System requirements

This tutorial requires a user account on any UNIX-based system that has a recentcopy of Emacs installed.

There are several varieties of Emacs; the original and most popular is GNU Emacs,which is published online by the GNU Project (see Resources).

You should have a recent copy of GNU Emacs—one that is at version 20 or greater.Versions 20 and 21 are the most commonly available, and development snapshotsof version 22 are also available. This tutorial works with any of these versions forEmacs. If your system is running something older, it's time to upgrade.

To know what version of Emacs you have running, use the GNU-style --versionflag:

$ emacs --versionGNU Emacs 22.0.91.1Copyright (C) 2006 Free Software Foundation, Inc.GNU Emacs comes with ABSOLUTELY NO WARRANTY.You may redistribute copies of Emacsunder the terms of the GNU General Public License.For more information about these matters, see the file named COPYING.$

You should also have the GNU Emacs documentation installed on your system.Although it's often bundled with the editor, sometimes the Info manual is availableseparately. Check with your system administrator to make sure you have it installed.

Section 2. Get help with your keystrokes

Emacs is called the self-documenting editor, because the Emacs help key isavailable to give you documentation about every command andkeystroke—whenever you're entering an Emacs command, you can use the help keyto get assistance. The Emacs help key is defined as C-h. All Emacs help facilitiesbegin with this prefix.

This section describes the help commands you can use to get help with particularkeystrokes.

Learn what a given keystroke is for

Every keystroke you can type in Emacs is documented, and there are a few waysEmacs can tell you what a particular keystroke is for.

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 3 of 32

The first and quickest way is through the describe-key-briefly function, whichlets you input a keystroke and then tells you, in the minibuffer, the name of thefunction that keystroke executes. It's bound to C-h c.

Start Emacs now, and try getting help with some keystrokes:

C-h c C-x C-cC-h c C-h lC-h c C-h c

You can also get more detailed information about a particular keystroke. Thedescribe-key function, C-h k, gives more information about a key or keystroke,opening a new help buffer in a help window that describes its use. Try running it witha letter key:

C-h k k

As you see from the new window that appears, the K key is bound to theself-insert-command function, which inserts the given keyboard character (inthis case, k) at point in the current buffer.

Try finding out what the C-x k command does:

C-h k C-x k

List all the key bindings that begin with a given prefix

The general help prefix, C-h, takes on a special meaning when you use it as apostfix —when you type C-h after some other control-character prefix, you get anew buffer that lists all the available key bindings for that prefix.

For example, the C-x keystroke is a frequently used prefix in Emacs. You learned inthe first tutorial in this series (see Resources) that the C-x C-c combination is theusual command to exit Emacs: As the save-buffers-kill-emacs function, itwrites all unsaved buffers to disk and then exits the program. You also learned thatC-x C-f runs find-file, which opens a file on the file system into a new buffer ofits own. But what else has a C-x prefix?

Find out: Type C-x C-h to get a list of possibilities.

When you type this, a new *Help* buffer opens, giving a list of all possiblekeystrokes that begin with the C-x keystroke.

In a previous tutorial in this series, you learned how to switch between windows andhow to resize them—type C-x o C-x 1 to move to the *Help* buffer window, andthen resize it to fill the Emacs frame, so your Emacs session looks like Figure 1.

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 4 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Figure 1. Getting a list of all possible C-x keystroke combinations

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 5 of 32

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 6 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

When you're done perusing the *Help* buffer, type C-k Enter to kill it.

Learn which commands you can complete

The Emacs help key is more than just a prefix: You can use it even if you're in themiddle of typing a command. Whenever you'd like to know which commands arepossible for what you've already typed, type C-h.

When you do this, Emacs opens a new *Help* buffer. This buffer shows whatcommands begin with and what you've already typed.

Try getting a list of possible commands for the C-x a keystrokes. Type C-x a C-h,and notice the new *Help* buffer that appears:

Global Bindings Starting With C-x a:key binding--- -------

C-x a C-a add-mode-abbrevC-x a ' expand-abbrevC-x a + add-mode-abbrevC-x a - inverse-add-global-abbrevC-x a e expand-abbrevC-x a g add-global-abbrevC-x a i Prefix CommandC-x a l add-mode-abbrevC-x a n expand-jump-to-next-slotC-x a p expand-jump-to-previous-slot

C-x a i g inverse-add-global-abbrevC-x a i l inverse-add-mode-abbrev

Learn what functions you can type

The Emacs minibuffer offers command completion, which works like its equivalent inthe Bash shell and many other UNIX shells.

When you're typing a function and you forget its entire name, you can usecompletion to get a hint. Press the Tab key whenever you're giving the name of afunction, command, or file, and Emacs completes it to the most unique valuepossible.

For instance, remember from the last tutorial in this series that Emacs can show youthe latest phases of the moon. But if you try typing M-x phases-of-the-moonright now, it doesn't work: Emacs reports no match when you tell it to execute thatfunction. Hmm. You know that this function began with phases. What was thecommand?

To find out, try running it with completion:

Type M-x pha Tab .

When you do this, Emacs completes the command for you. The correct function

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 7 of 32

appears in the minibuffer:

M-x phases-of-moon

Are any other functions available that begin with this name? Press Tab again to see,and look at what the minibuffer says:

M-x phases-of-moon [Sole completion]

If there were more options beginning with the text phases-of-moon, Emacs wouldhave shown you them.

Press Enter to run the sole completion.

Now, try listing all the functions available: Type M-x Tab . You can press Tabrepeatedly to scroll down in the list, and then type C-g to destroy the completion-listbuffer and cancel your command when you're done.

When more than one completion is possible and Emacs shows a *Completions*buffer in a new window that lists all the possibilities, you can scroll through thecompletions to select one in various ways:

• Click a completion with B2 to select it.

• Move to the *Completions* buffer (such as by typing C-x o), and thenpress Enter to select the completion nearest to point.

• Use the possibilities in the *Completions* buffer as a guide, and type outyour selection in the minibuffer.

To demonstrate, try the following:

1. Type M-< C-Spacebar M-> to select the comment code at the top ofthe *scratch* buffer as the region.

2. Type C-x mo Tab to pull up a *Completions* buffer that shows allfunctions beginning with the letters mo.

3. Click B2 on morse-region to select that function, which converts thetext in the region to Morse code.

4. Type C-x fi Tab to pull up a *Completions* buffer that shows allfunctions beginning with the letters fi.

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 8 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

5. Type C-x o C-x o to run the other-window function twice, movingthe cursor first from the minibuffer to the *scratch* buffer and then to the*Completions* buffer.

6. Type C-n enough times that the cursor is on the fill-region function,and then press Enter to select that function.

Now your Emacs session should look like Figure 2.

Figure 2. Running a command on the region using completion

View what you've typed

You can view and record a literal stream of all the keystrokes you type in Emacs,

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 9 of 32

which is useful for debugging. There are a few ways to do that.

Look at the lossage

The last 100 keystrokes you made inside Emacs is called the lossage. To view it,run the view-lossage function. It's bound to the C-h l keystroke.

When you run this command, it opens a new *Help* buffer and displays the currentkeyboard lossage in that buffer.

Try it: Type C-h l.

If you've been following along with the examples in this tutorial, your Emacs sessionshould now look like Figure 3.

Figure 3. Viewing the lossage in Emacs

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 10 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

It's important to note that Emacs stores the actual characters you type, not just thenames of the commands you run. To see the difference, exit Emacs and then startEmacs again, and view the lossage right away: Type M-x view-lossage Enter.

When you do this, you should see this lossage in the new *Help* window:

M-x v i e w - l o s s a g e <return>

Exit Emacs, start it again, and view the lossage by using completion a couple of

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 11 of 32

times to complete the command: Type M-x view Tab l Tab Enter .

When you do this, you run the same command as before, but the lossage looksdifferent:

M-x v i e w <tab> l <tab> <return>

Make a dribble file

If you want to view more than the last 100 keystrokes you've made, you can firstopen a dribble file; when you do so, Emacs dribbles a copy of everything you type, asingle keystroke at a time, into that file until you exit.

To make a dribble file, run the open-dribble-file function. Try it now:

1. Make a new dribble file: Type M-x open-dribble-file Entermydribbles Enter .

2. Type some text in the *scratch* buffer:

Nothing is ever really lost

3. View the lossage: Type M-x view-lossage Enter .

4. Exit Emacs: Type C-x C-c.

After you've done this, look at the contents of your dribble file. It should containevery character you just typed, including the control characters you used to specifyEmacs commands.

Summary of Emacs keystroke-help commands

Table 1 lists the various Emacs commands you can use to get help on keystrokes,giving their function name (if applicable) and describing their purpose.

Table 1. Summary of Emacs keystroke-help commandsKeystroke Function Description

Tab This command performscommand completion if given aspart of a command, showing allpossible input values for thegiven command.

command prefix or This command describes all the

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 12 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

keystroke C-h possible commands andfunctions available for the givencommand prefix or keystroke.

C-h c keystroke describe-key-briefly This command reports in theminibuffer the name of functionthat keystroke is bound to.

C-h k keystroke describe-key This command opens a newhelp-buffer window thatdescribes the function thatkeystroke is bound to.

C-h l view-lossage This command opens a newbuffer and displays the last 100characters typed.

open-dribble-file This command opens aspecified file and dribbles acopy of all keyboard input to thatfile.

Section 3. Get help with Emacs commands andfunctions

Just as Emacs gives you help on particular keystrokes, you can also get help onparticular commands and functions. This section describes those commands.

Learn which commands are right for a task

The command-apropos command tells you which Emacs commands areappropriate for a given keyword. You give this function by typing the help prefix andthe C key.

This is a good command to use when you know what you want to do—such as savea file or work with fonts—but you don't know the name of the command, or evenwhat commands are available for a given concept. Follow the command with aregular word or a regular expression, and it returns a new *Apropos* buffer that listsall of the commands whose name contains that word or regexp.

Try getting a list of commands having to do with help: Type C-h a help and lookat the contents of the *Apropos* buffer that appears. When you type C-x o C-x 1to fill the frame with the buffer, your Emacs session should look something likeFigure 4.

Figure 4. Emacs command apropos listing

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 13 of 32

Similarly, the apropos function (not bound to any key) lists not only commands andfunctions that are apropos to a given regexp, but it also lists Emacs variables, whichwere described in the previous tutorial in this series.

Try getting a list of functions, commands, and variables having to do with help: TypeM-x apropos Enter help Enter .

The new *Apropos* buffer that this function gives you lists all the functions you sawwith the previous example plus other variables.

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 14 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Learn what a function does

When you know the name of a function but aren't sure what it does, thedescribe-function help command, bound to C-h f, is useful. It prompts for thename of an Emacs function and tells you what it does.

Try getting a description of the view-lossage function: Type C-h fview-lossage.

When you do this, Emacs brings up a new *Help* buffer describing theview-lossage function.

(In the previous tutorial in this series, you learned about a similar help command:The describe-variable function, bound to C-h v, describes the contents of agiven variable.)

Learn what keystroke a function is bound to

Two important Emacs help commands relate to finding out what bindings are inplace and what keystroke a given function is bound to, if any.

The describe-bindings function, C-h b, opens a *Help* buffer listing all thecurrent bindings. If you want to know the binding for a particular function, use thewhere-is function, which is bound to C-h w. It describes, in the minibuffer, where(on the keyboard) you can find a given function.

Try asking Emacs to describe where the end-of-line function is: Type C-h wend-of-line.

Summary of Emacs function-help commands

Table 2 lists the Emacs commands you can use to get help on particular functions,giving the keystroke they're bound to (if applicable), the function name, and adescription of their purpose.

Table 2. Summary of Emacs function help commandsKeystroke Function Description

apropos This command gives a list ofapropos commands andvariables to a given regexp.

C-h a regexp command-apropos This command gives a list ofapropos commands to regexp.

C-h b describe-bindings This command describes all thevalid key bindings for the currentmajor mode in a new help bufferwindow.

C-h f function describe-function This command describes the

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 15 of 32

purpose of function in a newhelp buffer window.

C-h v variable describe-variable This command describes thepurpose of variable in a newhelp buffer window.

C-h w function where-is This command describes whichkeyboard binding (if any) aparticular function is bound to.

Section 4. Browse Info: the built-in documentationsystem

Emacs comes with a great deal of documentation, including a complete manual forusers. The manual is written in Info, which is the GNU Project's text-based hypertextdocumentation system (it precedes the World Wide Web). Although the GNU Infosystem also has an eponymous, standalone reader application (and many third-partyreader applications), you can also read Info documents inside Emacs.

Info documents have a hierarchical, tree-like structure. The basic unit of an Infodocument is the node, which is the rough equivalent to an HTML page on a Website; each node describes a topic or subtopic of that Info document.

Nodes contain the text of the document; nodes can also contain any number ofcross references, which are hyperlinks that take you to the nodes they reference.The newer versions of Emacs show cross references by highlighting them in color;but you can tell cross references even if you're in a text terminal, because theyalways begin with the text *Note: and then give the name of the node they refer to.

Nodes can also end with a menu, which is a list of cross-reference links, usually ofall the nodes that exist as subtopics beneath the current node. Menus begin with thetext * Menu: and then list the cross references on the lines immediately following.

Every Info document has a Top node, which is the starting point for that documenttree—think of it as the table of contents in a printed book. The Top node contains amain menu for that document, showing all the major subdivisions in the document.Documents usually also have an Index node containing a list of all nodes in thatdocument.

The GNU Info system keeps a directory of all Info documents stored on the systemin a special, main Top node called the Directory node. When new Info documentsare installed on the system (often in the /usr/share/info directory, but this differsacross different UNIX implementations), they're added to this node.

With the exception of the Directory node, nodes always have an Up node that bringsyou to the topic the current node is a subtopic of; the Up node of a document's Top

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 16 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

node is the main Directory node. Nodes can also have other nodes designated astheir Next and Previous nodes—those are nodes that are at a parallel level to thecurrent node in the document tree.

Figure 5 illustrates the GNU Info system's node structure, showing a simplified viewof the Directory node with example Info documents.

Figure 5. Sample GNU Info-document hierarchy

Start Info

The info function (bound to C-h i) starts Info, opening to the main Directory nodecontaining links to all the Info documents installed on the system.

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 17 of 32

Start Info by typing C-h i.

This opens a new *info* buffer containing your system's main Info Directory node.This is the highest Top node in the system. There are no nodes above it, nor does ithave a Next or Previous node; the only nodes available are the ones in its menu.

Select a node

Use the cursor keys to move down to the menu item for the Emacs node—it beginswith the text * Emacs: —and press Enter to select it.

When you do this, Info opens the Top node of the Emacs manual, as in Figure 6. Ithas an Up node (the Directory node you just came from) and a Next node, which isthe first chapterM in the manual. It also has a Previous node, which in this case isalso the Directory node.

Figure 6. Viewing the GNU Emacs manual in Info

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 18 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Move in and between nodes

There are a few ways to move through a node. Use the PgUp and PgDn keys toscroll through a node a screen at a time. When you use these keys, you scroll onlythrough the current node—once you reach the top or bottom of the node, you stop

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 19 of 32

scrolling in that direction.

Try using PgDn to move through the node you're in, showing the main menu of theEmacs manual.

You can also use the Spacebar and Backspace keys to scroll forward and backwardthrough the node and automatically move between nodes: If you encounter a menuwhile scrolling forward in the node, you immediately move to the first nodereferenced in that menu; and if you encounter the top of the node while scrollingbackward in the node, you immediately move to the top of that node's Previousnode.

When you use these two keys to scroll through nodes, you can cycle through anentire Info document. However, you can't move to another document in the Directorynode this way. Note in Figure 5 how all menu items form parallel links that you canmove between, except for menu items in the Directory node. In this example,suppose you're at the Gizmo manual node: Pressing the Spacebar repeatedly takesyou through that node to the following nodes:

• Using gizmos

• Turning them on

• Turning them off

• Replacing gizmos

Try pressing the Spacebar several times to move to the Next node and then throughit and several other nodes.

You can also move to the Next and Previous nodes at any time by pressing N and P,respectively.

To move to the Up node, press U; and to move to the last node you visited beforethe current node, press L.

To follow a particular item in a menu or a cross reference given somewhere in anode, move the cursor onto it and press Enter. You can also use the mouse byclicking B2 on the link.

Try moving through the Emacs documentation using the commands you've justlearned.

Search for a topic

You can use several techniques to search inside Info. One way uses theInfo-index command, bound to the I key, which searches the Index node of that

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 20 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

document for the given text.

Try searching for info in the Emacs manual:

1. Press I to run the Info-index command.

2. At the Index topic: prompt, type info Enter .

When you do this, Emacs displays the page of the manual that discusses using Info.

You can also search incrementally through the current node by using the Emacsisearch-forward function, which is bound to C-s and was described earlier inthis series.

Search forward through the current node for info: Type C-s info to move thecursor to the next instance of the text, and then type C-s repeatedly to cycle throughall the instances of info in that node.

To search for text through the current node and all other nodes, use theInfo-search function, bound to the S key. It moves to the next instance of thegiven text anywhere in the Info document.

Try searching for info again:

1. Type M-> to move to the end of the node.

2. Press S to run the Info-search function.

3. In the minibuffer, type info Enter .

When you do this, Emacs moves to the next instance of the text info, which occurs inanother node in the document.

Leaving Info

There are a few different ways to put Info behind you.

To switch to another buffer and move the Info buffer to the background of the bufferlist, press Q.

Try it now, and see how Emacs displays another buffer; then type C-x b *info*Enter to move back to the *info* buffer.

To kill the *info* buffer, type C-x k (just as you would with any buffer). *info* is

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 21 of 32

removed from your buffer list; to view it again, type C-h i to start from thebeginning.

Summary of Emacs Info commands

Table 3 lists the various keystroke commands that are available in Info mode anddescribes their function.

Table 3. Summary of Emacs Info mode commandsKeystroke Function Description

H Info-help This command opens ahands-on Info tutorial in a newbuffer.

Q Info-exit This command moves to the lastbuffer you visited, putting the*info* buffer in the end of thebuffer list.

EnterorB2

This command follows the crossreference at or near point.

N Info-next This command moves to thecurrent node's Next node.

P Info-prev This command moves to thecurrent node's Previous node.

U Info-up This command moves to thecurrent node's Up node.

D Info-directory This command moves to theDirectory node.

L Info-last This command moves to the lastnode you visited.

T Info-top-node This command moves to theTop node of the currentdocument.

> Info-final-node This command moves to thefinal node pointed to in thecurrent document.

Spacebar Info-scroll-up This command moves forwardin the current node by a singlescreen; if at the end of the node,then move to the Next node.

Backspace Info-scroll-down This command moves backwardin the current node by a singlescreen; if at the beginning of thenode, then move to the Previousnode.

B beginning-of-buffer This command goes to thebeginning of the current node.

S Info-search This command searches

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 22 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

forward in the current Infodocument for a given regexp.

Tab Info-next-reference This command moves thecursor forward to the first crossreference.

M-Tab Info-prev-reference This command moves thecursor backward to the lastcross reference.

Section 5. Read the documentation files

In addition to the GNU Emacs manual and other GNU manuals that you can read inInfo, the GNU Emacs editor comes with a few special built-in document files, andthey are available for reading inside Emacs at a keystroke.

Read about what's new

A revision log of the latest versions of Emacs is readable inside Emacs by runningthe view-emacs-news function, which is bound to C-h n.

Try running it now to see the latest changes in the version of Emacs you haveinstalled on your system: Type C-h n.

When you type this, Emacs opens a new buffer named NEWS. Notice the twopercentage signs in the mode line, showing that the buffer is marked read-only.

Learn the licensing

The GNU General Public License (GNU GPL), that famous copyleft software licensethat kicked off the new methodology of networked collaboration that brought aboutopen source software, is available for reading when you run thedescribe-copying function, which is bound to C-h C-c.

You can also learn about the Emacs warranty (there is none), which is described atthe bottom of the license. Go straight to these details with thedescribe-no-warranty function, which is bound to C-h C-w.

Learn about the GNU Project

The describe-project function, bound to C-h C-p, is a 7,500-word essay byRichard Stallman, Emacs' principal author, describing the purpose of the GNUProject (which he founded).

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 23 of 32

The GNU Manifesto is a famous document that was distributed on the Internet in theearly years of the GNU Project; it's one of the first nodes in the GNU Emacs manual,which you can read by opening the Emacs manual in an *info* buffer, as describedin Select a node section:

1. Type C-h i to open an *info* buffer.

2. Use C-n to move down to the Emacs manual, and select it by pressingEnter on the * Emacs: menu item.

3. Use C-n to move down to the * Manifesto: menu item, and press Enterto select it.

The describe-distribution function, bound to C-h C-d, tells you how you canobtain a recent copy of Emacs directly from the GNU Project.

Bring up the FAQ

The GNU Emacs FAQ is an Info document containing many frequently askedquestions pertaining to the installation and use of Emacs. You can read a copy inEmacs by running the view-emacs-faq function, which is bound to C-h F.

A useful section of this document is the Common requests node, which contains along listing of common improvements and customizations that people generally wantto do with Emacs.

Try viewing that node: Type i req Enter , and your Emacs session should looklike Figure 7.

Figure 7. Viewing the "Common requests" node of the GNU Emacs FAQ inInfo.

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 24 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 25 of 32

Read about obscure problems

The GNU Project keeps a list of obscure implementation problems that peoplesometimes encounter while running Emacs and the solutions those users havefound to overcome them. This list is available by running theview-emacs-problems function, which is bound to C-h P.

Summary of Emacs help files

Table 4 lists some of the documentation files that come with Emacs and gives thefunctions and keystrokes used to view them, as well as their descriptions. Thesefiles are normally kept in the etc subdirectory of the main Emacs directory tree,which on many UNIX systems is found at /usr/share/emacs/VERSION/etc/, whereVERSION is the version number of the copy of Emacs that is installed. This directorycontains many more documentation-related files of varying utility.

Table 4. Summary of Emacs documentation filesKeystroke Function Filename Description

C-h C-d describe-distributionDISTRIB Information onobtaining a copy of thelatest distribution of theEmacs software

C-h F view-emacs-faq /usr/share/info/emacs-mainversion/efaq.gzEmacs FAQ

C-h C-c describe-copying COPYING GNU General PublicLicense (GNU GPL)

C-h C-w describe-no-warrantyCOPYING Section "NOWARRANTY" of theGNU General PublicLicense (GNU GPL)

C-h n view-emacs-news NEWS News concerning thelatest changes in thecurrent version ofEmacs

C-h P view-emacs-problemsPROBLEMS Emacs problems file

C-h C-p describe-project THE-GNU-PROJECT Essay by RichardStallman concerningthe founding of theGNU Project

C-h t help-with-tutorial TUTORIAL Hands-on tutorial forlearning the basics ofEmacs

Section 6. Summary

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 26 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

Get help on help

As in the List all the key bindings that begin with a given prefix section, you can usethe C-h Emacs help key as a postfix to get help on C-h itself.

Try it: Type C-h C-h.

Doing so runs the Emacs help-for-help function, which opens a new *Help*buffer containing all the Emacs help commands. As in an Info node, you can pressSpacebar and Backspace to scroll forward and backward through the buffer, or youcan use the initial of a help command to run that command. Press Q to exit this Helpmenu.

Summary of Emacs help commands

Table 5 lists all the Emacs help commands and describes their functions.

Table 5. Summary of Emacs help commandsKeystroke Function Description

apropos This command gives a list ofapropos commands andvariables to a given regexp.

open-dribble-file This command opens aspecified file and dribbles acopy of all keyboard input to thatfile.

Tab This command performscommand completion if given aspart of a command, showing allpossible input values for thegiven command.

command prefix orkeystroke C-h

This command describes allpossible commands andfunctions available for the givencommand prefix or keystroke.

C-h C-c describe-copying This command views the GNUGeneral Public License (GNUGPL).

C-h C-d describe-distribution This command viewsinformation on obtaining a copyof the latest distribution of theEmacs software.

C-h C-p describe-project This command views an essayby Richard Stallman concerningthe founding of the GNUProject.

C-h C-w describe-no-warranty This command views the "NOWARRANTY" section of the

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 27 of 32

GNU GPL.

C-h a regexp command-apropos This command gives a list ofapropos commands to regexp.

C-h b describe-bindings This command describes allvalid key bindings for the currentmajor mode in a new help bufferwindow.

C-h c keystroke describe-key-briefly This command reports in theminibuffer the name of functionthat keystroke is bound to.

C-h F view-emacs-faq This command views the EmacsFAQ Info document.

C-h f function describe-function This command describes thepurpose of function in a newhelp buffer window.

C-h k keystroke describe-key This command opens a newhelp buffer window thatdescribes the function thatkeystroke is bound to.

C-h l view-lossage This command opens a newbuffer, and displays the last 100characters typed.

C-h n view-emacs-news This command views newsconcerning the latest changes inthe current version of Emacs.

C-h P view-emacs-problems This command views the Emacsproblems file.

C-h t help-with-tutorial This command opens ahands-on tutorial for learning thebasics of Emacs.

C-h v variable describe-variable This command describes thepurpose of variable in a newhelp buffer window.

C-h w function where-is This command describes whichkeyboard binding (if any) aparticular function is bound to.

Wrap-up

Emacs is a large and complex application and, as you've just seen, it has a built-inhelp system to match. You've learned how to use it, getting Emacs to help you atevery level: identifying keystrokes, commands, and functions; giving you lists ofmeaningful, possible, and appropriate commands; presenting the Emacs manualthat you can browse with the built-in documentation system; and showing you theother informative files that come with Emacs.

After this, you know enough about getting automatic assistance whenever you'restuck, so the next time it happens, you can ask Emacs to help you out.

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 28 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 29 of 32

Resources

Learn

• "Emacs editing environment": Check out other parts in this series.

• "Use free software within commercial UNIX" (David Dougall, developerWorks,February 2006): Learn how to install GNU Emacs on the IBM® AIX® operatingsystem or another commercial UNIX.

• Emacs commands: The IBM DB2® Universal Database™ (UDB) InformationCenter has a quick summary of basic Emacs commands.

• IBM Redbooks: Read Open Source Software for z/OS and OS/390 UNIX IBMfor a brief history of the free software movement, including Richard Stallman'sGNU Project and the origins of GNU Emacs, and information on installing andtroubleshooting Emacs.

• GNU Project and the Free Software Foundation: Learn more about the GNUProject and the Free Software Foundation from its Web site.

• GNU Emacs Lisp Reference Manual: Learn more about Emacs Lisp with thisofficial GNU manual.

• Check out other articles and tutorials written by Michael Stutz:

• AIX and UNIX zone

• Across developerWorks and IBM

• AIX and UNIX: The AIX and UNIX developerWorks zone provides a wealth ofinformation relating to all aspects of AIX systems administration and expandingyour UNIX skills.

• New to AIX and UNIX?: Visit the "New to AIX and UNIX" page to learn moreabout AIX and UNIX.

• Search the AIX and UNIX library by topic:

• System administration

• Application development

• Performance

• Porting

• Security

• Tips

• Tools and utilities

• Java™ technology

• Linux®

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 30 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.

• Open source

• AIX Wiki: A collaborative environment for technical information related to AIX.

• Safari bookstore: Visit this e-reference library to find specific technicalresources.

• developerWorks technical events and webcasts: Stay current withdeveloperWorks technical events and webcasts.

• Podcasts: Tune in and catch up with IBM technical experts.

Get products and technologies

• GNU Project Web site: Download a free copy of the latest GNU Emacs for yourOS and architecture free of charge.

• IBM trial software: Build your next development project with software fordownload directly from developerWorks.

Discuss

• Participate in the developerWorks blogs and get involved in the developerWorkscommunity.

• Participate in the AIX and UNIX forums:

• AIX—technical forum

• AIX 6 Open Beta

• AIX for Developers Forum

• Cluster Systems Management

• IBM Support Assistant

• Performance Tools—technical

• Virtualization—technical

• More AIX and UNIX forums

About the author

Michael StutzMichael Stutz is author of The Linux Cookbook , which he also designed and typesetusing only open source software. His research interests include digital publishing andthe future of the book. He has used various UNIX operating systems for 20 years.You can reach Michael at [email protected]. (Be sure to include "developerWorks" in thesubject line.)

ibm.com/developerWorks developerWorks®

Let Emacs help you out© Copyright IBM Corporation 1994, 2008. All rights reserved. Page 31 of 32

Trademarks

IBM, AIX, and DB2 are registered trademarks of International Business MachinesCorporation in the United States, other countries, or both.Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in theUnited States, other countries, or both.Linux is a registered trademark of Linus Torvalds in the United States, othercountries, or both.UNIX is a registered trademark of The Open Group in the United States and othercountries.

developerWorks® ibm.com/developerWorks

Let Emacs help you outPage 32 of 32 © Copyright IBM Corporation 1994, 2008. All rights reserved.