From b1f2aa11bdad6f07baef54ac6db15ee714d3941e Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Thu, 9 Dec 2021 17:36:14 +0100 Subject: [PATCH 3/3] Switch back to minibuffer when quitting completion buffer * lisp/simple.el (completion-quit): Add new command (completion-list-mode-map): Rebind completion-quit over keyboard-quit and delete-completion-window over keyboard-quit. --- lisp/simple.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisp/simple.el b/lisp/simple.el index 6a7d7ba918..74deb4bdc4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8971,6 +8971,12 @@ 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)) + (defvar completion-list-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map special-mode-map) @@ -8988,6 +8994,8 @@ completion-list-mode-map (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 [remap keyboard-quit] #'delete-completion-window) + (define-key map [remap quit-window] #'completion-quit) map) "Local map for completion list buffers.") -- 2.30.2