[Editorial Note: Sorry about the lousy formatting. Org2blog is misbehaving again so I had to paste the HTML into the WordPress editor.]
Ben Maughan over at Pragmatic Emacs has a really nice tip. It's one of
those things that you (or at least I) don't think about but once you
see the tip, you think, “That's just what I need.” The idea is to kill
the current buffer without asking.
Maughan asks how many times you've called
【Ctrl+x k】and wanted to kill some buffer other than the one you're in. I can't
ever remember doing that. Maughan provides a one line fix to your
init.el that will just delete the current buffer without asking.
If you think you'll sometimes want the old behavior and don't want to
kill-buffer, it's trivial to add a bit of Elisp that
kill-this-buffer unless the universal argument is provided in
which case it calls
kill-buffer. Bind this to
【Ctrl+x k】 and you have the best of both worlds.
Here's some code that does that
(defun jcs-kill-a-buffer (askp) (interactive "P") (if askp (kill-buffer (funcall completing-read-function "Kill buffer: " (mapcar #'buffer-name (buffer-list)))) (kill-this-buffer))) (global-set-key (kbd "C-x k") 'jcs-kill-a-buffer)