emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestions for improvements to the *Completions* buffer


From: Philip Kaludercic
Subject: Re: Suggestions for improvements to the *Completions* buffer
Date: Mon, 13 Dec 2021 21:36:33 +0000

Philip Kaludercic <philipk@posteo.net> writes:

> From 8f2433d70eadef47772b01b71ff44f5010c0935b Mon Sep 17 00:00:00 2001
> From: Philip Kaludercic <philipk@posteo.net>
> 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)

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.

The question is whether or not there is a need for a separate
switch-to-minibuffer binding (besides M-g M-c)?  Is keeping the
completions buffer active while returning to the minibuffer a real need?

>      map)
>    "Local map for completion list buffers.")

-- 
        Philip Kaludercic



reply via email to

[Prev in Thread] Current Thread [Next in Thread]