all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gregory Heytings <gregory@heytings.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 47699@debbugs.gnu.org
Subject: bug#47699: [PATCH] Improve completion-list-mode-map
Date: Mon, 12 Apr 2021 07:24:25 +0000	[thread overview]
Message-ID: <94e9dae987fc8ea25890@heytings.org> (raw)
In-Reply-To: <3755fe92dce0690564f0@heytings.org>

[-- Attachment #1: Type: text/plain, Size: 210 bytes --]


>> Right here, I think.
>
> Okay, so what do you and others think of the following:
>

Here is the complete patch, with an improved 
read-expression-switch-to-completions function, so that you can try it 
out.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff; name=Switch-between-minibuffer-and-Completions.patch, Size: 4299 bytes --]

From 3027053dbd3759f0c12bf5855e95931bf51dd492 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Mon, 12 Apr 2021 07:15:03 +0000
Subject: [PATCH] Switch between minibuffer and *Completions*

* lisp/simple.el (completion-list-mode-map): Make special-mode-map its
parent, unbind the 'g' revert key, bind the 'n' and 'p' keys to
next-completion and previous-completion, and the M-g key to
switch-to-minibuffer.
(read-expression-map): Bing M-g to read-expression-switch-to-completions.
(switch-to-minibuffer, read-expression-switch-to-completions): New
functions.

* lisp/minibuffer.el (minibuffer-local-completion-map): Bind the M-g key
to switch-to-completion.

* doc/emacs/windows.texi (Temporary Displays): Document the change.
---
 doc/emacs/windows.texi |  8 +++++---
 lisp/minibuffer.el     |  1 +
 lisp/simple.el         | 18 ++++++++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi
index c66deb7748..2e942e4082 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -541,9 +541,11 @@ Temporary Displays
 @findex temp-buffer-resize-mode
   The @file{*Completions*} buffer is also special in the sense that
 Emacs usually tries to make its window just as large as necessary to
-display all of its contents.  To resize windows showing other
-temporary displays, like, for example, the @file{*Help*} buffer, turn
-on the minor mode (@pxref{Minor Modes}) @code{temp-buffer-resize-mode}
+display all of its contents, and that you can switch back and forth
+between the minibuffer and the @file{*Completions*} buffer by typing
+@key{M-g}.  To resize windows showing other temporary displays, like,
+for example, the @file{*Help*} buffer, turn on the minor mode
+(@pxref{Minor Modes}) @code{temp-buffer-resize-mode}
 (@pxref{Temporary Displays,,Temporary Displays, elisp, The Emacs Lisp
 Reference Manual}).
 
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5f594679ca..d555784133 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2413,6 +2413,7 @@ minibuffer-local-completion-map
     (define-key map "?" 'minibuffer-completion-help)
     (define-key map [prior] 'switch-to-completions)
     (define-key map "\M-v"  'switch-to-completions)
+    (define-key map "\M-g"  'switch-to-completions)
     map)
   "Local keymap for minibuffer input with completion.")
 
diff --git a/lisp/simple.el b/lisp/simple.el
index 999755a642..57e9e868cb 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1658,6 +1658,7 @@ read-expression-map
     (define-key m "\t" 'completion-at-point)
     (define-key m "\r" 'read--expression-try-read)
     (define-key m "\n" 'read--expression-try-read)
+    (define-key m "\M-g" 'read-expression-switch-to-completions)
     (set-keymap-parent m minibuffer-local-map)
     m))
 
@@ -8767,6 +8768,8 @@ set-variable
 
 (defvar completion-list-mode-map
   (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map special-mode-map)
+    (define-key map "g" nil) ;; There's nothing to revert from.
     (define-key map [mouse-2] 'choose-completion)
     (define-key map [follow-link] 'mouse-face)
     (define-key map [down-mouse-2] nil)
@@ -8778,6 +8781,9 @@ completion-list-mode-map
     (define-key map [backtab] 'previous-completion)
     (define-key map "q" 'quit-window)
     (define-key map "z" 'kill-current-buffer)
+    (define-key map "n" 'next-completion)
+    (define-key map "p" 'previous-completion)
+    (define-key map "\M-g" 'switch-to-minibuffer)
     map)
   "Local map for completion list buffers.")
 
@@ -9067,6 +9073,18 @@ switch-to-completions
       ;; FIXME: Perhaps this should be done in `minibuffer-completion-help'.
       (when (bobp)
 	(next-completion 1)))))
+
+(defun read-expression-switch-to-completions ()
+  "Select the completion list window while reading an expression."
+  (interactive)
+  (completion-help-at-point)
+  (switch-to-completions))
+
+(defun switch-to-minibuffer ()
+  "Select the minibuffer window."
+  (interactive)
+  (when (active-minibuffer-window)
+    (select-window (active-minibuffer-window))))
 \f
 ;;; Support keyboard commands to turn on various modifiers.
 
-- 
2.30.2


  reply	other threads:[~2021-04-12  7:24 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11  1:03 bug#47699: [PATCH] Improve completion-list-mode-map Gregory Heytings
2021-04-11  7:24 ` Eli Zaretskii
2021-04-11  7:31 ` Eli Zaretskii
2021-04-11  7:58   ` Gregory Heytings
2021-04-11  8:14     ` Eli Zaretskii
2021-04-11  8:31       ` Gregory Heytings
2021-04-11  8:34         ` Eli Zaretskii
2021-04-11 10:14           ` Gregory Heytings
2021-04-11 10:40             ` Eli Zaretskii
2021-04-11 10:50               ` Gregory Heytings
2021-04-11 13:31                 ` Eli Zaretskii
2021-04-11 18:30                   ` Gregory Heytings
2021-04-11 18:46                     ` Eli Zaretskii
2021-04-11 19:13                       ` Gregory Heytings
2021-04-11 19:37                         ` Eli Zaretskii
2021-04-11 20:44                           ` Gregory Heytings
2021-04-12  7:24                             ` Gregory Heytings [this message]
2021-04-11 18:59                     ` bug#47699: [External] : " Drew Adams
2021-04-11 19:21                       ` Gregory Heytings
2021-04-11 22:33                         ` Drew Adams
2021-04-12  6:49                           ` Gregory Heytings
2021-04-12 14:50                             ` Drew Adams
2021-05-25  4:39                     ` Lars Ingebrigtsen
2021-05-25  7:32                       ` Gregory Heytings
2021-05-25  7:37                         ` Lars Ingebrigtsen
2021-05-25  8:34                           ` Gregory Heytings
2021-05-25  8:40                             ` Lars Ingebrigtsen
2021-05-25  8:42                               ` Gregory Heytings
2021-05-25 12:31                       ` Basil L. Contovounesios
2021-05-25 19:22                         ` Lars Ingebrigtsen
2021-05-25 19:25                         ` Gregory Heytings
2021-05-25 19:27                           ` Gregory Heytings
2021-04-11 22:36         ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94e9dae987fc8ea25890@heytings.org \
    --to=gregory@heytings.org \
    --cc=47699@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.