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'd like to make emacs not just bury a buffer but kill it too when i press "q" in a *Completions*/*Help*/etc buffer. I cant get the substitute-key-definition function to work. I'm running emacs24 on osx.

Heres what I have:

(substitute-key-definition
        'quit-window '(lambda () (interactive) (quit-window "KILL")) global-map)
share|improve this question
    
Have you got any particular reason for also wanting to kill it? –  N.N. Mar 7 '12 at 17:13
    
@N.N E.g. once i've seen a completion i dont need it to be still open after quitting the window its in. –  bneil Mar 7 '12 at 21:09
add comment

2 Answers 2

up vote 2 down vote accepted

The other answer actually gives slightly incompatible behavior. Consider a situation where you already have a frame split into two windows, then you open a help buffer and quit it. quit-window is smart enough to know that it shouldn't kill the window, just the buffer. It actually even has a few more clever tricks up its sleeve so our best bet is to work with it and just tweak it a bit. Here's a simple way of achieving what you want:

(defadvice quit-window (before quit-window-always-kill)
  "When running `quit-window', always kill the buffer."
  (ad-set-arg 0 t))
(ad-activate 'quit-window)
share|improve this answer
add comment

Just redefining the function seemed to have worked for me ie

(defun quit-window () 
 "modified quit window"
 (interactive)
 (kill-buffer-and-window)
 )

I've never understood the purpose of having a completion or help buffer still available when you are switching buffers after you pressed q to quit it previously.

share|improve this answer
add comment

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.