Next: , Previous: Hideshow, Up: Programs


31.8 Completion for Symbol Names

In Emacs, completion is something you normally do in the minibuffer. But one kind of completion is available in all buffers: completion for symbol names.

The character M-<TAB> runs a command to complete the partial symbol before point against the set of meaningful symbol names. This command inserts at point any additional characters that it can determine from the partial name. (If your window manager defines M-<TAB> to switch windows, you can type <ESC> <TAB> or C-M-i.)

If the partial name in the buffer has multiple possible completions that differ in the very next character, so that it is impossible to complete even one more character, M-<TAB> displays a list of all possible completions in another window.

In most programming language major modes, M-<TAB> runs the command complete-symbol, which provides two kinds of completion. Normally it does completion based on a tags table (see Tags); with a numeric argument (regardless of the value), it does completion based on the names listed in the Info file indexes for your language. Thus, to complete the name of a symbol defined in your own program, use M-<TAB> with no argument; to complete the name of a standard library function, use C-u M-<TAB>. Of course, Info-based completion works only if there is an Info file for the standard library functions of your language, and only if it is installed at your site.

In Emacs-Lisp mode, the name space for completion normally consists of nontrivial symbols present in Emacs—those that have function definitions, values or properties. However, if there is an open-parenthesis immediately before the beginning of the partial symbol, only symbols with function definitions are considered as completions. The command which implements this is lisp-complete-symbol.

In Text mode and related modes, M-<TAB> completes words based on the spell-checker's dictionary. See Spelling.