johnbakers
johnbakers

Reputation: 24771

How to close a buffer you don't need any more

What's the easiest way to close a buffer in emacs? This would be synonymous with closing an actual file, right? It would probably prompt you to save, if necessary.

I found this in the Emacs help:

s-^ kill-some-buffers

But I don't know how to invoke that or what it means.

Upvotes: 2

Views: 254

Answers (1)

Vebjorn Ljosa
Vebjorn Ljosa

Reputation: 18008

kill-buffer, which is usually bound to C-x k:

C-x k runs the command kill-buffer, which is an interactive built-in function in `C source code'.

It is bound to C-x k.

(kill-buffer &optional BUFFER-OR-NAME)

Kill the buffer specified by BUFFER-OR-NAME. The argument may be a buffer or the name of an existing buffer. Argument nil or omitted means kill the current buffer. Return t if the buffer is actually killed, nil otherwise.

The functions in kill-buffer-query-functions are called with the buffer to be killed as the current buffer. If any of them returns nil, the buffer is not killed. The hook kill-buffer-hook is run before the buffer is actually killed. The buffer being killed will be current while the hook is running. Functions called by any of these hooks are supposed to not change the current buffer.

Any processes that have this buffer as the process-buffer are killed with SIGHUP. This function calls replace-buffer-in-windows for cleaning up all windows currently displaying the buffer to be killed.

Upvotes: 2

Related Questions