Juri Linkov writes: >>> - (define-key map "z" 'kill-current-buffer) >>> (define-key map "\M-g\M-c" 'switch-to-minibuffer) >>> + (define-key map "z" #'completion-kill-buffer) >>> + (define-key map [remap keyboard-quit] #'completion-quit) >>> + (define-key map [remap quit-window] #'switch-to-minibuffer) >> >> It seems that remapping quit-window to switch-to-minibuffer creates >> issues when the completion buffer is not invoked by the minibuffer, but >> e.g. by complete-symbol. Binding it to completion-quit (defined above) >> instead, might actually be more natural, as "q"/quit-window is expected >> to close a window. > > Good point, so `q' should not be rebound from its standard command > `quit-window'. Like you noticed, currently `quit-window' fails > to select the minibuffer window, but this is a bug, so this regression > was reported in bug#52491. Ok, great! > Then "z" could be bound to a variant of `quit-window' > that calls it with the argument KILL non-nil. So something like this?