Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm wondering how it can be done, so Emacs doesn't pop the prompt asking me whether I really want to kill current buffer with C-x k shortcut.

Interesting thing is that same action done via toolbar kills buffer instantly without prompting the user. Any solution? Thank you.

share|improve this question

3 Answers 3

up vote 6 down vote accepted

By default, Emacs doesn't ask you if you want to kill the buffer. It does ask you which buffer you want to kill.

If you don't want to be asked which buffer you want to kill, you can use this:

(global-set-key (kbd "C-x k") 'kill-this-buffer)

If you're being prompted for confirmation, then there's something in your .emacs (or the site specific initialziation). Try running emacs -q to check Emacs w/out your .emacs.

Note: Verified with Emacs 23.2.

share|improve this answer
'kill-this-buffer is part of emacs and that should be used instead. –  Jaseem Feb 26 at 19:02

You can find out what that menu entry does with C-h k and then clicking on the entry. It turns out to be a command named kill-this-buffer.

Then you can bind that command to a key combination:

(global-set-key "\C-xk" 'kill-this-buffer)
share|improve this answer

I use this

(global-set-key (kbd "C-x k") (lambda ()
                              (kill-buffer (buffer-name))))
share|improve this answer
Minor improvement: (kill-buffer (current-buffer)) –  Jaseem Feb 26 at 19:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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