[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

F. Running Commands by Name

Every Emacs command has a name that you can use to run it. Commands that are used often, or that must be quick to type, are also bound to keys--short sequences of characters--for convenient use. You can run them by name if you don't remember the keys. Other Emacs commands that do not need to be quick are not bound to keys; the only way to run them is by name. See section AD.4 Customizing Key Bindings, for the description of how to bind commands to keys.

By convention, a command name consists of one or more words, separated by hyphens; for example, auto-fill-mode or manual-entry. The use of English words makes the command name easier to remember than a key made up of obscure characters, even though it is more characters to type.

The way to run a command by name is to start with M-x, type the command name, and finish it with RET. M-x uses the minibuffer to read the command name. RET exits the minibuffer and runs the command. The string `M-x' appears at the beginning of the minibuffer as a prompt to remind you to enter the name of a command to be run. See section E. The Minibuffer, for full information on the features of the minibuffer.

You can use completion to enter the command name. For example, you can invoke the command forward-char by name by typing either

 
M-x forward-char RET

or

 
M-x forw TAB c RET

Note that forward-char is the same command that you invoke with the key C-f. You can run any Emacs command by name using M-x, whether or not any keys are bound to it.

If you type C-g while the command name is being read, you cancel the M-x command and get out of the minibuffer, ending up at top level.

To pass a numeric argument to the command you are invoking with M-x, specify the numeric argument before the M-x. M-x passes the argument along to the command it runs. The argument value appears in the prompt while the command name is being read.

If the command you type has a key binding of its own, Emacs mentions this in the echo area, two seconds after the command finishes (if you don't type anything else first). For example, if you type M-x forward-word, the message says that you can run the same command more easily by typing M-f. You can turn off these messages by setting suggest-key-bindings to nil.

Normally, when describing in this manual a command that is run by name, we omit the RET that is needed to terminate the name. Thus we might speak of M-x auto-fill-mode rather than M-x auto-fill-mode RET. We mention the RET only when there is a need to emphasize its presence, such as when we show the command together with following arguments.

M-x works by running the command execute-extended-command, which is responsible for reading the name of another command and invoking it.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Dohn Arms on March, 6 2005 using texi2html