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: Sat, 18 Dec 2021 13:39:04 +0000

Po Lu <luangruo@yahoo.com> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> Here are the patches that would implement this behaviour.  I have to use
>> it for a bit longer before I can say if it is preferable, but I guess if
>> something along these lines were to be applied, this could be an option.
>
> Could this part be made optional, at least for those of us with muscle
> memory?  I actually expect the focus to return to the previous window
> (not necessarily the minibuffer) when I press `z' in a completion
> buffer.

Sure, that was a mistake on end.  I don't even think it needs an option,
so I just removed the code entirely:

>From b1f2aa11bdad6f07baef54ac6db15ee714d3941e 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/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

> Thanks.

-- 
        Philip Kaludercic

reply via email to

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