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 5 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") 
        '(lambda () (interactive) 
           (let (kill-buffer-query-functions) (kill-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

I use this

(global-set-key (kbd "C-x k") (lambda ()
                              (interactive)
                              (kill-buffer (buffer-name))))
share|improve this answer

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

Your Answer

 
discard

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.