I'm learning about emacs (using version 2.3 on Ubuntu 10.10), and I'm having some trouble with the frames. When I run gdb, for example, I have to get my mouse and click "File->Close" to close the gdb frame. What's the easiest way to close a frame from keyboard? By the way, is there a summary for this keyboard shortcuts?


I think you refer to killing the gdb buffer rather than closing a frame (which in Emacs refers to a window). To kill the buffer you are in type C-x k.

To get a descriptions of a certain command you can use C-h k. So for File - Close you can type C-h k and click File - Close. Emacs will then show a description about that function. You can use the same approach to show a description for C-x k by typing C-h k C-x k.

You can also go the other way (from a function to a command). Say that you find out that some key has to do with killing buffers and you want to know what other things you can kill and the commands this. Then you could type C-h f to get descriptions of functions. So, for instance, type C-h f and write 'kill' then press Tab to show the functions starting with 'kill'. Choose any function, such as kill-sentence and Emacs will show a description of it and what key it is bound to.

| improve this answer | |

In Emacs, “close” is often called “kill” or “delete”. The command to close a frame is delete-frame, bound to C-x 5 0 by default. C-x 5 is the prefix for frame commands.

Note that a frame, in Emacs terminology, is what most of the world calls a window; a window, in Emacs terminology, is what part of the world calls a pane. (Frames contain one or more windows, windows contain one or more pane.) The notion that corresponds to a file or an application running inside Emacs is a buffer. At any time, each window is showing a buffer, and a buffer can be shown in one or more frames or none at all. Unlike most other multi-document applications, Emacs does not tie edited objects (files and such) to user interface elements (windows). To close a file or application, kill the buffer: kill-buffer, bound to C-x k; type C-x k RET to kill the current buffer.

If you know the name of a command, you can find out what key(s) it's bound to by running where-is, which itself is bound to C-h w (C-h for help — you can also type f1 — and w for “where is this command”). So for example, to figure out what key delete-frame is bound to if any, type C-h w delete-frame RET (as usual, tab completion works).

To figure out what the command is called, you can run apropos-command (C-h a). For example, C-h a buffer RET shows the list of commands whose name contains “buffer” (there are a lot of those), with a one-line help summary for each. If you have already located the command in a menu, you can press C-h k (describe-key) then click on the menu entry, and this will show the help for the command. If you press C-h c (describe-key-briefly), Emacs will show just the name of the command in the message line. In addition to the self-documentation features, you can of course look things up in the manual (C-h r to read the manual).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.