>From 8f2433d70eadef47772b01b71ff44f5010c0935b Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Thu, 9 Dec 2021 17:36:14 +0100 Subject: [PATCH 3/4] Switch back to minibuffer when quitting completion buffer * lisp/simple.el (completion-quit): Add new command (completion-kill-buffer): Add new command (completion-list-mode-map): Bind completion-quit and rebind kill-current-buffer to completion-kill-buffer --- lisp/simple.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/simple.el b/lisp/simple.el index b5f5122153..5ca8142548 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8957,6 +8957,18 @@ set-variable ;; Define the major mode for lists of completions. +(defun completion-quit () + "Close the completion buffer and return to the minibuffer." + (interactive) + (quit-window) + (switch-to-minibuffer)) + +(defun completion-kill-buffer () + "Close the completion buffer and return to the minibuffer." + (interactive) + (kill-buffer "*Completions*") + (switch-to-minibuffer)) + (defvar completion-list-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map special-mode-map) @@ -8970,10 +8982,12 @@ completion-list-mode-map (define-key map [right] 'next-completion) (define-key map [?\t] 'next-completion) (define-key map [backtab] 'previous-completion) - (define-key map "z" 'kill-current-buffer) (define-key map "n" 'next-completion) (define-key map "p" 'previous-completion) (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) map) "Local map for completion list buffers.") -- 2.34.0