next up previous contents index
Next: Asking Emacs for Help Up: Editing files with Emacs Previous: Searching and Replacing

What's Really Going On Here?

Actually, all these keybindings you have been learning are shortcuts to Emacs functions. For example, C-p is a short way of telling Emacs to execute the internal function previous-line. However, all these internal functions can be called by name, using M-x. If you forgot that previous-line is bound to C-p, you could just type M-x previous-line tex2html_wrap8352 , and it would move you up one line. Try this now, to understand how M-x previous-line and C-p are really the same thing.

The designer of Emacs started from the ground up, first defining a whole lot of internal functions, and then giving keybindings to the most commonly-used ones. Sometimes it's easier just to call a function explicitly with M-x than to remember what key it's bound to. The function query-replace, for example, is bound to M-% in some versions of Emacs. But who can remember such an odd keybinding? Unless you use query-replace extremely often, it's easier just to call it with M-x.

Most of the keys you type are letters, meant to be inserted into the text of the buffer. So each of those keys is bound to the function self-insert-command, which does nothing but insert that letter into the buffer. Combinations that use the tex2html_wrap8336 key with a letter are generally bound to functions that do other things, like moving you around. For example, C-v is bound to a function called scroll-up, which scrolls the buffer up by one screenful (meaning that your position in the buffer moves down, of course).

If you ever actually wanted to insert a Control character into the buffer, then, how would you do it? After all, the Control characters are ASCII characters, although rarely used, and you might want them in a file. There is a way to prevent Control characters from being interpreted as commands by Emacs. The key C-qgif is bound to a special function named quoted-insert. All quoted-insert does is read the next key and insert it literally into the buffer, without trying to interpret it as a command. This is how you can put Control characters into your files using Emacs. Naturally, the way to insert a C-q is to press C-q twice!

Emacs also has many functions that are not bound to any key. For example, if you're typing a long message, you don't want to have to hit return at the end of every line. You can have Emacs do it for you (you can have Emacs do anything for you)--the command to do so is called auto-fill-mode, but it's not bound to any keys by default. In order to invoke this command, you would type `` M-x auto-fill-mode''. ``M-x'' is the key used to call functions by name. You could even use it to call functions like next-line and previous-line, but that would be very inefficient, since they are already bound to C-n and C-p!

By the way, if you look at your mode line after invoking auto-fill-mode, you will notice that the word ``Fill'' has been added to the right side. As long as it's there, Emacs will fill (wrap) text automatically. You can turn it off by typing `` M-x auto-fill-mode'' again--it's a toggle command.

The inconvenience of typing long function names in the minibuffer is lessened because Emacs does completion on function names the same way it does on file names. Therefore, you should rarely find yourself typing in the whole function name, letter by letter. If you're not sure whether or not you can use completion, just hit tex2html_wrap8288 . It can't hurt: the worst thing that will happen is that you'll just get a tab character, and if you're lucky, it'll turn out that you can use completion.


next up previous contents index
Next: Asking Emacs for Help Up: Editing files with Emacs Previous: Searching and Replacing

Converted on:
Mon Apr 1 08:59:56 EST 1996