all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#47699: [PATCH] Improve completion-list-mode-map
@ 2021-04-11  1:03 Gregory Heytings
  2021-04-11  7:24 ` Eli Zaretskii
  2021-04-11  7:31 ` Eli Zaretskii
  0 siblings, 2 replies; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11  1:03 UTC (permalink / raw)
  To: 47699

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


Currently completion-list-mode-map does not give a specific meaning to 
most keys, which means that most keypresses display an error "Buffer is 
read-only #<buffer *Completions*>".  I suggest to make it a child of 
special-mode-map, and to bind the "n" and "p" keys to "next-completion" 
and "previous-completion".

Patch attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff; name=0001-Improve-completion-list-mode-map.patch, Size: 1315 bytes --]

From 53dd1bcb56e743452f5bb825f46c60ed19ae72d1 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Sun, 11 Apr 2021 00:53:54 +0000
Subject: [PATCH] Improve completion-list-mode-map

* lisp/simple.el (completion-list-mode-map): Make special-mode-map its
parent, unbind the 'g' revert key, add the 'n' and 'p' keys for
next-completion and previous-completion.
---
 lisp/simple.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lisp/simple.el b/lisp/simple.el
index 999755a642..82ac6fc6b3 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8767,6 +8767,8 @@ makes it easier to edit it."
 
 (defvar completion-list-mode-map
   (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map special-mode-map)
+    (define-key map "g" nil) ;; nothing to revert
     (define-key map [mouse-2] 'choose-completion)
     (define-key map [follow-link] 'mouse-face)
     (define-key map [down-mouse-2] nil)
@@ -8778,6 +8780,8 @@ makes it easier to edit it."
     (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)
     map)
   "Local map for completion list buffers.")
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  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
  1 sibling, 0 replies; 33+ messages in thread
From: Eli Zaretskii @ 2021-04-11  7:24 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

> Date: Sun, 11 Apr 2021 01:03:56 +0000
> From: Gregory Heytings <gregory@heytings.org>
> 
> Currently completion-list-mode-map does not give a specific meaning to 
> most keys, which means that most keypresses display an error "Buffer is 
> read-only #<buffer *Completions*>".  I suggest to make it a child of 
> special-mode-map, and to bind the "n" and "p" keys to "next-completion" 
> and "previous-completion".
> 
> Patch attached.

Thanks.

Since your legal paperwork is not yet complete, please wait with
posting patches until that time, so that people will not be tempted to
install more of your changes when we are way past the threshold of
what we can accept without an assignment.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  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
  1 sibling, 1 reply; 33+ messages in thread
From: Eli Zaretskii @ 2021-04-11  7:31 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

> Date: Sun, 11 Apr 2021 01:03:56 +0000
> From: Gregory Heytings <gregory@heytings.org>
> 
> Currently completion-list-mode-map does not give a specific meaning to 
> most keys, which means that most keypresses display an error "Buffer is 
> read-only #<buffer *Completions*>".  I suggest to make it a child of 
> special-mode-map, and to bind the "n" and "p" keys to "next-completion" 
> and "previous-completion".

Why just 'n' and 'p'?  If we want more commands to move between
completions, I could think about several others: <, >, C-f, C-b, C-n,
C-p, Home, End, the arrow keys, etc.

However, these bindings are only available if one makes *Completions*
the current buffer, right?  Which rarely if ever happens in
TAB-completion scenarios, right?  If so, is that really helpful to
have these additional bindings, and if so, in what use cases?





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11  7:31 ` Eli Zaretskii
@ 2021-04-11  7:58   ` Gregory Heytings
  2021-04-11  8:14     ` Eli Zaretskii
  0 siblings, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11  7:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47699


>> Currently completion-list-mode-map does not give a specific meaning to 
>> most keys, which means that most keypresses display an error "Buffer is 
>> read-only #<buffer *Completions*>".  I suggest to make it a child of 
>> special-mode-map, and to bind the "n" and "p" keys to "next-completion" 
>> and "previous-completion".
>
> Why just 'n' and 'p'?  If we want more commands to move between 
> completions, I could think about several others: <, >, C-f, C-b, C-n, 
> C-p, Home, End, the arrow keys, etc.
>

It's not "just 'n' and 'p'", it adds 'n' and 'p' to the already available 
choices, completion-list-mode-map already defines:

TAB, right = next-completion
backtab, left = previous-completion

and C-{p,n} and the arrow keys work as usual.

>
> However, these bindings are only available if one makes *Completions* 
> the current buffer, right?
>

Yes, of course.

>
> Which rarely if ever happens in TAB-completion scenarios, right?  If so, 
> is that really helpful to have these additional bindings, and if so, in 
> what use cases?
>

Well, vanilla Emacs defines M-v = switch-to-completions, which opens 
*Completions* and makes it the current buffer.  In a selection-like 
scenario, it makes sense to switch to the completions buffer where you can 
freely move around, use isearch, and so forth.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11  7:58   ` Gregory Heytings
@ 2021-04-11  8:14     ` Eli Zaretskii
  2021-04-11  8:31       ` Gregory Heytings
  0 siblings, 1 reply; 33+ messages in thread
From: Eli Zaretskii @ 2021-04-11  8:14 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

> Date: Sun, 11 Apr 2021 07:58:04 +0000
> From: Gregory Heytings <gregory@heytings.org>
> cc: 47699@debbugs.gnu.org
> 
> > Why just 'n' and 'p'?  If we want more commands to move between 
> > completions, I could think about several others: <, >, C-f, C-b, C-n, 
> > C-p, Home, End, the arrow keys, etc.
> 
> It's not "just 'n' and 'p'"

The question was why add only those 2.

> Well, vanilla Emacs defines M-v = switch-to-completions, which opens 
> *Completions* and makes it the current buffer.  In a selection-like 
> scenario, it makes sense to switch to the completions buffer where you can 
> freely move around, use isearch, and so forth.

I wonder how many people use this paradigm

(And how does one switch back without closing the window that shows
completions?)





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11  8:14     ` Eli Zaretskii
@ 2021-04-11  8:31       ` Gregory Heytings
  2021-04-11  8:34         ` Eli Zaretskii
  2021-04-11 22:36         ` Juri Linkov
  0 siblings, 2 replies; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11  8:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47699


>>> Why just 'n' and 'p'?  If we want more commands to move between 
>>> completions, I could think about several others: <, >, C-f, C-b, C-n, 
>>> C-p, Home, End, the arrow keys, etc.
>>
>> It's not "just 'n' and 'p'"
>
> The question was why add only those 2.
>

As many as you want could be added.  But there are already three ways to 
move between completions.  < and > are assigned by special-mode-map to 
beginning-of-buffer and end-of-buffer.  IMO changing the C-{fbnp} commands 
is not necessary, given that that moving around with their usual meaning 
makes sense.

>> Well, vanilla Emacs defines M-v = switch-to-completions, which opens 
>> *Completions* and makes it the current buffer.  In a selection-like 
>> scenario, it makes sense to switch to the completions buffer where you 
>> can freely move around, use isearch, and so forth.
>
> I wonder how many people use this paradigm
>

I do, from time to time.  I'd be surprised if I were the only one, as I 
remember that it's something I already did during the first days I used 
Emacs.  When you see a window with lots of information appearing, is it 
not natural to enter that window and to move around?

>
> (And how does one switch back without closing the window that shows 
> completions?)
>

C-x o.  Perhaps it would make sense to bind "o" for this, too.  And/or 
"Q".  WDYT?





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11  8:31       ` Gregory Heytings
@ 2021-04-11  8:34         ` Eli Zaretskii
  2021-04-11 10:14           ` Gregory Heytings
  2021-04-11 22:36         ` Juri Linkov
  1 sibling, 1 reply; 33+ messages in thread
From: Eli Zaretskii @ 2021-04-11  8:34 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

> Date: Sun, 11 Apr 2021 08:31:00 +0000
> From: Gregory Heytings <gregory@heytings.org>
> cc: 47699@debbugs.gnu.org
> 
> > (And how does one switch back without closing the window that shows 
> > completions?)
> 
> C-x o.  Perhaps it would make sense to bind "o" for this, too.  And/or 
> "Q".  WDYT?

'o' could be a good idea, IMO.

But I'm puzzled by the lack of symmetry: why bind M-v when "C-x o" is
available.  But I guess that ship sailed long ago.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11  8:34         ` Eli Zaretskii
@ 2021-04-11 10:14           ` Gregory Heytings
  2021-04-11 10:40             ` Eli Zaretskii
  0 siblings, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11 10:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47699


>>> (And how does one switch back without closing the window that shows 
>>> completions?)
>>
>> C-x o.  Perhaps it would make sense to bind "o" for this, too.  And/or 
>> "Q".  WDYT?
>
> 'o' could be a good idea, IMO.
>

Okay.

>
> But I'm puzzled by the lack of symmetry:
>

If you agreed with it, I would be pleased to add symmetry there.  I use 
M-c for both purposes locally:

(define-key minibuffer-local-map (kbd "M-c") 'switch-to-completions) 
(define-key completion-list-mode-map (kbd "M-c") 'other-window)

>
> why bind M-v when "C-x o" is available.
>

Because M-v does something very different: it opens the *Completions*. 
So it's the equivalent of TAB TAB C-- C-x o.

>
> But I guess that ship sailed long ago.
>

Yes, M-v was already present in Emacs 20.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 10:14           ` Gregory Heytings
@ 2021-04-11 10:40             ` Eli Zaretskii
  2021-04-11 10:50               ` Gregory Heytings
  0 siblings, 1 reply; 33+ messages in thread
From: Eli Zaretskii @ 2021-04-11 10:40 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

> Date: Sun, 11 Apr 2021 10:14:14 +0000
> From: Gregory Heytings <gregory@heytings.org>
> cc: 47699@debbugs.gnu.org
> 
> If you agreed with it, I would be pleased to add symmetry there.  I use 
> M-c for both purposes locally:
> 
> (define-key minibuffer-local-map (kbd "M-c") 'switch-to-completions) 
> (define-key completion-list-mode-map (kbd "M-c") 'other-window)

I don't think other-window is the right command, because with some
window configurations it might land you in the wrong window.  It has
to be a command that lands you back in the mini-window.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 10:40             ` Eli Zaretskii
@ 2021-04-11 10:50               ` Gregory Heytings
  2021-04-11 13:31                 ` Eli Zaretskii
  0 siblings, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11 10:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47699


>> If you agreed with it, I would be pleased to add symmetry there.  I use 
>> M-c for both purposes locally:
>>
>> (define-key minibuffer-local-map (kbd "M-c") 'switch-to-completions)
>> (define-key completion-list-mode-map (kbd "M-c") 'other-window)
>
> I don't think other-window is the right command, because with some 
> window configurations it might land you in the wrong window.  It has to 
> be a command that lands you back in the mini-window.
>

In practice other-window works well there, but now that you mention it, I 
agree with you that it's not safe enough.  What about:

(defun switch-to-minibuffer ()
   "Select the minibuffer window."
   (interactive)
   (when (active-minibuffer-window)
     (select-window (active-minibuffer-window))))





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 10:50               ` Gregory Heytings
@ 2021-04-11 13:31                 ` Eli Zaretskii
  2021-04-11 18:30                   ` Gregory Heytings
  0 siblings, 1 reply; 33+ messages in thread
From: Eli Zaretskii @ 2021-04-11 13:31 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

> Date: Sun, 11 Apr 2021 10:50:15 +0000
> From: Gregory Heytings <gregory@heytings.org>
> cc: 47699@debbugs.gnu.org
> 
> In practice other-window works well there, but now that you mention it, I 
> agree with you that it's not safe enough.  What about:
> 
> (defun switch-to-minibuffer ()
>    "Select the minibuffer window."
>    (interactive)
>    (when (active-minibuffer-window)
>      (select-window (active-minibuffer-window))))

LGTM, thanks.  Did you test this with minibuffer-only frames?





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 13:31                 ` Eli Zaretskii
@ 2021-04-11 18:30                   ` Gregory Heytings
  2021-04-11 18:46                     ` Eli Zaretskii
                                       ` (2 more replies)
  0 siblings, 3 replies; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11 18:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47699

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


>
> LGTM, thanks.  Did you test this with minibuffer-only frames?
>

Thanks.  Here is the updated patch.  I tested it with minibuffer-only 
frames, and it seems to work.

Are you sure that it's okay to rebind M-c in 
minibuffer-local-completion-map?  It's a good mnemonic for "completion", 
but it hides the capitalize-word binding, that users might possibly want 
to use there (I don't, it's only when thinking about this patch that I 
realized this).

Another option would be M-g, which would not hide anything that is 
possibly useful in the minibuffer, and is still a mnemonic of "goto".

[-- Attachment #2: Type: text/x-diff, Size: 2493 bytes --]

From 2af79f204cbb30f36722b912e1ac0aff060283bd Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Sun, 11 Apr 2021 18:10:29 +0000
Subject: [PATCH] Improve completion-list-mode-map

* lisp/simple.el (completion-list-mode-map): Make special-mode-map its
parent, unbind the 'g' revert key, add the 'n' and 'p' keys for
next-completion and previous-completion, and the M-c key for
switch-to-minibuffer.
(switch-to-minibuffer): New function

* lisp/minibuffer.el (minibuffer-local-completion-map): Add the M-c key
for switch-to-completion.
---
 lisp/minibuffer.el |  1 +
 lisp/simple.el     | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5f594679ca..d18a0f7461 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-c"  'switch-to-completions)
     map)
   "Local keymap for minibuffer input with completion.")
 
diff --git a/lisp/simple.el b/lisp/simple.el
index 999755a642..232177204d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8767,6 +8767,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 +8780,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-c" 'switch-to-minibuffer)
     map)
   "Local map for completion list buffers.")
 
@@ -9067,6 +9072,12 @@ switch-to-completions
       ;; FIXME: Perhaps this should be done in `minibuffer-completion-help'.
       (when (bobp)
 	(next-completion 1)))))
+
+(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


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 18:30                   ` Gregory Heytings
@ 2021-04-11 18:46                     ` Eli Zaretskii
  2021-04-11 19:13                       ` Gregory Heytings
  2021-04-11 18:59                     ` bug#47699: [External] : " Drew Adams
  2021-05-25  4:39                     ` Lars Ingebrigtsen
  2 siblings, 1 reply; 33+ messages in thread
From: Eli Zaretskii @ 2021-04-11 18:46 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

> Date: Sun, 11 Apr 2021 18:30:03 +0000
> From: Gregory Heytings <gregory@heytings.org>
> cc: 47699@debbugs.gnu.org
> 
> Are you sure that it's okay to rebind M-c in 
> minibuffer-local-completion-map?

No, I was only talking about the command itself.  The binding needs a
separate discussion, I think.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [External] : bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 18:30                   ` Gregory Heytings
  2021-04-11 18:46                     ` Eli Zaretskii
@ 2021-04-11 18:59                     ` Drew Adams
  2021-04-11 19:21                       ` Gregory Heytings
  2021-05-25  4:39                     ` Lars Ingebrigtsen
  2 siblings, 1 reply; 33+ messages in thread
From: Drew Adams @ 2021-04-11 18:59 UTC (permalink / raw)
  To: Gregory Heytings, Eli Zaretskii; +Cc: 47699@debbugs.gnu.org

> Are you sure that it's okay to rebind M-c in
> minibuffer-local-completion-map?  It's a good mnemonic for "completion",
> but it hides the capitalize-word binding, that users might possibly want
> to use there (I don't, it's only when thinking about this patch that I
> realized this).
> 
> Another option would be M-g, which would not hide anything that is
> possibly useful in the minibuffer, and is still a mnemonic of "goto".

FWIW, my voice says don't do any of this.  Just
leave keymap `completion-list-mode-map' alone.
(Likewise, the minibuffer keymaps.)

Yes, I can (and do) override whatever bindings
are unwise there.  Still...

As for a key to switch between the minibuffer
and *Completions*, FWIW Icicles uses `C-<insert>',
by default.  (Has done so for decades.)

And the commands for that key don't just switch
windows.  Moving to *Completions* puts the cursor
on the first occurrence of the current minibuffer
content, and moving to the minibuffer inserts the
current candidate in `*Completions*' (under the
cursor) as the current candidate for the minibuffer.

If vanilla Emacs insists on binding a key for
switching windows, for Icicles users it would be
better for vanilla Emacs to use `C-<insert>' as
well - the behavior would be similar with and
without Icicles.

IMO, `M-c' or any other editing key is a poor
choice for anything in the minibuffer.  For the
most part,uUsers should be able to do ordinary
editing in the minibuffer - including `M-c'.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 18:46                     ` Eli Zaretskii
@ 2021-04-11 19:13                       ` Gregory Heytings
  2021-04-11 19:37                         ` Eli Zaretskii
  0 siblings, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11 19:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47699


>> Are you sure that it's okay to rebind M-c in 
>> minibuffer-local-completion-map?
>
> No, I was only talking about the command itself.  The binding needs a 
> separate discussion, I think.
>

Where?  I don't want to start another keybinding discussion on 
emacs-devel, last time I did it wasn't a pleasant experience...





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [External] : bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 18:59                     ` bug#47699: [External] : " Drew Adams
@ 2021-04-11 19:21                       ` Gregory Heytings
  2021-04-11 22:33                         ` Drew Adams
  0 siblings, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11 19:21 UTC (permalink / raw)
  To: Drew Adams; +Cc: 47699


>> Are you sure that it's okay to rebind M-c in 
>> minibuffer-local-completion-map?  It's a good mnemonic for 
>> "completion", but it hides the capitalize-word binding, that users 
>> might possibly want to use there (I don't, it's only when thinking 
>> about this patch that I realized this).
>>
>> Another option would be M-g, which would not hide anything that is 
>> possibly useful in the minibuffer, and is still a mnemonic of "goto".
>
> FWIW, my voice says don't do any of this.  Just leave keymap 
> `completion-list-mode-map' alone.
>

Why?  Almost no keys are defined in completion-list-mode-map, so why would 
it not be okay to define a few of them?

>
> (Likewise, the minibuffer keymaps.)
>

Why?  And as I just said, if some object against M-c (as you just did), 
M-g is the other choice, its meanings in global-map can't be used in the 
minibuffer.

>
> As for a key to switch between the minibuffer and *Completions*, FWIW 
> Icicles uses `C-<insert>', by default.
>

C-<insert> doesn't exist on laptop keyboard, and can't be used in a 
terminal, so it isn't exactly a good candidate.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 19:13                       ` Gregory Heytings
@ 2021-04-11 19:37                         ` Eli Zaretskii
  2021-04-11 20:44                           ` Gregory Heytings
  0 siblings, 1 reply; 33+ messages in thread
From: Eli Zaretskii @ 2021-04-11 19:37 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

> Date: Sun, 11 Apr 2021 19:13:32 +0000
> From: Gregory Heytings <gregory@heytings.org>
> cc: 47699@debbugs.gnu.org
> 
> 
> >> Are you sure that it's okay to rebind M-c in 
> >> minibuffer-local-completion-map?
> >
> > No, I was only talking about the command itself.  The binding needs a 
> > separate discussion, I think.
> >
> 
> Where?

Right here, I think.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 19:37                         ` Eli Zaretskii
@ 2021-04-11 20:44                           ` Gregory Heytings
  2021-04-12  7:24                             ` Gregory Heytings
  0 siblings, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-04-11 20:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47699


>
> Right here, I think.
>

;-)

Okay, so what do you and others think of the following:

1. bind M-g in minibuffer-local-completion-map to switch-to-completions

2. bind M-g in completion-list-mode-map to switch-to-minibuffer, defined as follows:

(defun switch-to-minibuffer ()
   "Select the minibuffer window."
   (interactive)
   (when (active-minibuffer-window)
     (select-window (active-minibuffer-window))))

3. bind M-g in read-expression-map to read-expression-switch-to-completion, defined as follows:

(defun read-expression-switch-to-completions ()
   "Select the completion list window."
   (interactive)
   (let ((completion-auto-help t)
         (minibuffer-message-timeout 0))
     (completion-at-point)
     (switch-to-completions)))





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [External] : bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 19:21                       ` Gregory Heytings
@ 2021-04-11 22:33                         ` Drew Adams
  2021-04-12  6:49                           ` Gregory Heytings
  0 siblings, 1 reply; 33+ messages in thread
From: Drew Adams @ 2021-04-11 22:33 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699@debbugs.gnu.org

> > FWIW, my voice says don't do any of this.  Just leave keymap
> > `completion-list-mode-map' alone.
> 
> Why?  Almost no keys are defined in completion-list-mode-map,
> so why would it not be okay to define a few of them?

I didn't say it isn't okay.  It's okay, of course.
I prefer that you don't; that's all.

I bind keys in it.  The more vanilla keys Emacs
binds there, the more I'll need to worry about
changing default bindings, and the more new users
will perhaps expect vanilla keys.

> > (Likewise, the minibuffer keymaps.)
> 
> Why?

Same reason - but a thousand times stronger.
Much more time (in Icicles) is spent in the
minibuffer than is ever spent in *Completions* -
thousands, maybe millions more key uses there
(not even counting self-inserting keys).

> And as I just said, if some object against M-c (as you just did),
> M-g is the other choice, its meanings in global-map can't be used 
> in the minibuffer.

Its global meanings can't be used in the minibuffer,
but other, minibuffer-specific meanings can.  I bind
lots of keys, including `M-g', in the minibuffer maps
(for Icicle minor mode).

The logic you're following, that key XYZ is "free",
and that its global binding is useless in the
minibuffer, is fine.  It's the same logic that others,
3rd-party libraries, use.  It's yet another case of
Emacs conquering more territory for itself, leaving
less for 3rd-party code.

Yes, I know things are different for a minor-mode
map.  Nothing prevents Icicle mode from continuing
with the same bindings.  Still, I'd prefer that
Emacs leave it alone - as it has done for 40 years. 

> C-<insert> doesn't exist on laptop keyboard, and can't be
> used in a terminal, so it isn't exactly a good candidate.

Is `emacs -nw' considered a "terminal"?  (I can never
remember the nuances)  If so then I can use it in a
terminal.  And users with laptops that don't have it
can rebind the command.  I haven't heard a complaint
about it (and I have heard about other keys not OK
for terminals).

But suit yourself.  I use it partly because "insert"
is mnemonic (for the Icicles behavior, which doesn't
just switch to another window).





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11  8:31       ` Gregory Heytings
  2021-04-11  8:34         ` Eli Zaretskii
@ 2021-04-11 22:36         ` Juri Linkov
  1 sibling, 0 replies; 33+ messages in thread
From: Juri Linkov @ 2021-04-11 22:36 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

>>> Well, vanilla Emacs defines M-v = switch-to-completions, which opens
>>> *Completions* and makes it the current buffer.  In a selection-like
>>> scenario, it makes sense to switch to the completions buffer where you
>>> can freely move around, use isearch, and so forth.
>>
>> I wonder how many people use this paradigm
>
> I do, from time to time.  I'd be surprised if I were the only one, as
> I remember that it's something I already did during the first days I used
> Emacs.  When you see a window with lots of information appearing, is it not
> natural to enter that window and to move around?

I use this all the time: type PgUp to switch to the completions buffer,
then use the same key PgUp together with PgDn to scroll completions,
and use isearch to search in completions.

The existing useful key 'q' closes the completions buffer,
and switches back to the minibuffer.

But then I have such customization, with it using the completions buffer
is more handy:

(defun choose-completion-no-auto-exit ()
  (interactive)
  (let ((completion-no-auto-exit t))
    (call-interactively 'choose-completion)))

(define-key completion-list-mode-map [M-return] 'choose-completion-no-auto-exit)

where M-RET inserts the selected completion to the minibuffer without exiting it,
and switches back to the minibuffer.





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [External] : bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 22:33                         ` Drew Adams
@ 2021-04-12  6:49                           ` Gregory Heytings
  2021-04-12 14:50                             ` Drew Adams
  0 siblings, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-04-12  6:49 UTC (permalink / raw)
  To: Drew Adams; +Cc: 47699


>>> FWIW, my voice says don't do any of this.  Just leave keymap 
>>> `completion-list-mode-map' alone.
>>
>> Why?  Almost no keys are defined in completion-list-mode-map, so why 
>> would it not be okay to define a few of them?
>
> I bind keys in it.
>
>>> (Likewise, the minibuffer keymaps.)
>>
>> Why?
>
> Same reason
>

I don't want to start another keybinding dispute with you, but it seems to 
me that you are wrong.  Can you perhaps explain how you (and Icicles 
users) would be affected by this change?  You said that you already have a 
(different) keybinding that does what I suggest, and that you bind the M-g 
key in the minibuffer to something else.  IOW, this change will have zero 
effect on you (and Icicles users): it will neither override one of your 
keys nor make one of the functionalities of vanilla Emacs unavailable for 
you (and Icicles users).





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 20:44                           ` Gregory Heytings
@ 2021-04-12  7:24                             ` Gregory Heytings
  0 siblings, 0 replies; 33+ messages in thread
From: Gregory Heytings @ 2021-04-12  7:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 47699

[-- 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


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* bug#47699: [External] : bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-12  6:49                           ` Gregory Heytings
@ 2021-04-12 14:50                             ` Drew Adams
  0 siblings, 0 replies; 33+ messages in thread
From: Drew Adams @ 2021-04-12 14:50 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699@debbugs.gnu.org

> this change will have zero
> effect on you (and Icicles users): it will neither
> override one of your keys nor make one of the
> functionalities of vanilla Emacs unavailable for
> you (and Icicles users).

I already explained.  The more keys you bind
there the more new Icicles users might expect
those vanilla keys.  There's no key conflict
per se, except possibly in the habits and minds
of users.

I already corrected your claim that I'm saying
it's somehow not OK to do what you propose.
I said, "I prefer that you don't; that's all."
I just made a request; you seem to want to argue. 






^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-04-11 18:30                   ` Gregory Heytings
  2021-04-11 18:46                     ` Eli Zaretskii
  2021-04-11 18:59                     ` bug#47699: [External] : " Drew Adams
@ 2021-05-25  4:39                     ` Lars Ingebrigtsen
  2021-05-25  7:32                       ` Gregory Heytings
  2021-05-25 12:31                       ` Basil L. Contovounesios
  2 siblings, 2 replies; 33+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-25  4:39 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

Gregory Heytings <gregory@heytings.org> writes:

> Thanks.  Here is the updated patch.  I tested it with minibuffer-only
> frames, and it seems to work.
>
> Are you sure that it's okay to rebind M-c in
> minibuffer-local-completion-map?  It's a good mnemonic for
> "completion", but it hides the capitalize-word binding, that users
> might possibly want to use there (I don't, it's only when thinking
> about this patch that I realized this).
>
> Another option would be M-g, which would not hide anything that is
> possibly useful in the minibuffer, and is still a mnemonic of "goto".

Thanks; applied to Emacs 28.

I went with `M-g' -- it seems pretty natural here.  If anybody else
wants a different key binding, go ahead and change it.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-05-25  4:39                     ` Lars Ingebrigtsen
@ 2021-05-25  7:32                       ` Gregory Heytings
  2021-05-25  7:37                         ` Lars Ingebrigtsen
  2021-05-25 12:31                       ` Basil L. Contovounesios
  1 sibling, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-05-25  7:32 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 47699

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


>> Thanks.  Here is the updated patch.  I tested it with minibuffer-only 
>> frames, and it seems to work.
>>
>> Are you sure that it's okay to rebind M-c in 
>> minibuffer-local-completion-map?  It's a good mnemonic for 
>> "completion", but it hides the capitalize-word binding, that users 
>> might possibly want to use there (I don't, it's only when thinking 
>> about this patch that I realized this).
>>
>> Another option would be M-g, which would not hide anything that is 
>> possibly useful in the minibuffer, and is still a mnemonic of "goto".
>
> Thanks; applied to Emacs 28.
>
> I went with `M-g' -- it seems pretty natural here.  If anybody else 
> wants a different key binding, go ahead and change it.
>

Juri said recently that he uses some of the keys in M-g in the minibuffer, 
so I changed my mind, and I now think that it would be better to use 'M-g 
M-c' for this, which is unused, and does not hide the complete M-g map. 
Updated patch attached.  WDYT?

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

From 4d6a33038e820c6043d71635fee241951229241e Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Tue, 25 May 2021 07:19:41 +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 M-c key to
switch-to-minibuffer.
(read-expression-map): Bind M-g M-c 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 M-c
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..4ab641e784 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -541,9 +541,11 @@ the following form in your initialization file (@pxref{Init File}):
 @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 M-c}.  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 e04f1040b3..ec21b7b93b 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2603,6 +2603,7 @@ The completion method is determined by `completion-at-point-functions'."
     (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\M-c"  'switch-to-completions)
     map)
   "Local keymap for minibuffer input with completion.")
 
diff --git a/lisp/simple.el b/lisp/simple.el
index 2a90a07631..cac3058825 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1661,6 +1661,7 @@ in *Help* buffer.  See also the command `describe-char'."
     (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\M-c" 'read-expression-switch-to-completions)
     (set-keymap-parent m minibuffer-local-map)
     m))
 
@@ -8834,6 +8835,8 @@ makes it easier to edit it."
 
 (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)
@@ -8845,6 +8848,9 @@ makes it easier to edit it."
     (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\M-c" 'switch-to-minibuffer)
     map)
   "Local map for completion list buffers.")
 
@@ -9133,6 +9139,18 @@ select the completion near point.\n\n"))))))
       ;; 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


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-05-25  7:32                       ` Gregory Heytings
@ 2021-05-25  7:37                         ` Lars Ingebrigtsen
  2021-05-25  8:34                           ` Gregory Heytings
  0 siblings, 1 reply; 33+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-25  7:37 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

Gregory Heytings <gregory@heytings.org> writes:

> Juri said recently that he uses some of the keys in M-g in the
> minibuffer, so I changed my mind, and I now think that it would be
> better to use 'M-g M-c' for this, which is unused, and does not hide
> the complete M-g map. Updated patch attached.  WDYT?

Sure, `M-g M-c' is fine by me.  But could you send a new patch against
the current tree?  The previous version of the patch has already been
applied and pushed.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-05-25  7:37                         ` Lars Ingebrigtsen
@ 2021-05-25  8:34                           ` Gregory Heytings
  2021-05-25  8:40                             ` Lars Ingebrigtsen
  0 siblings, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-05-25  8:34 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 47699

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


>> Juri said recently that he uses some of the keys in M-g in the 
>> minibuffer, so I changed my mind, and I now think that it would be 
>> better to use 'M-g M-c' for this, which is unused, and does not hide 
>> the complete M-g map. Updated patch attached.  WDYT?
>
> Sure, `M-g M-c' is fine by me.  But could you send a new patch against 
> the current tree?  The previous version of the patch has already been 
> applied and pushed.
>

Hmmm...  Why did you remove "read-expression-switch-to-completions" from 
the patch?  I know that you can, in vanilla Emacs, achieve the same effect 
with TAB TAB C-- C-x o, which is I think too complicated.  Patch attached, 
against the current trunk.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff; name=Further-improvements-to-completion-list-mode-map.patch, Size: 4316 bytes --]

From a5f1e8a16df0d4fc8616c2b77830f0646ecf79d1 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Tue, 25 May 2021 08:20:26 +0000
Subject: [PATCH] Further improvements to completion-list-mode-map

* lisp/simple.el (completion-list-mode-map): Change the M-g key to M-g M-c.
(read-expression-map): Bind M-g M-c to read-expression-switch-to-completions.
(read-expression-switch-to-completions): New function.

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

* doc/emacs/mini.texi (Completion Commands): Mention the change, and mention
the 'n' and 'p' keys bound to 'next-completion' and 'previous-completion'.
---
 doc/emacs/mini.texi | 6 ++++--
 etc/NEWS            | 4 ++--
 lisp/minibuffer.el  | 2 +-
 lisp/simple.el      | 9 ++++++++-
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 564e576300..2fdb1e7072 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -375,8 +375,8 @@ Completion Commands
 Typing @kbd{M-v}, while in the minibuffer, selects the window showing
 the completion list (@code{switch-to-completions}).  This paves the
 way for using the commands below.  @key{PageUp}, @key{prior} and
-@kbd{M-g} does the same.  You can also select the window in other ways
-(@pxref{Windows}).
+@kbd{M-g M-c} does the same.  You can also select the window in other
+ways (@pxref{Windows}).
 
 @findex choose-completion
 @item @key{RET}
@@ -388,12 +388,14 @@ Completion Commands
 @findex next-completion
 @item @key{TAB}
 @item @key{RIGHT}
+@item @key{n}
 While in the completion list buffer, these keys move point to the
 following completion alternative (@code{next-completion}).
 
 @findex previous-completion
 @item @key{S-TAB}
 @item @key{LEFT}
+@item @key{p}
 While in the completion list buffer, these keys move point to the
 previous completion alternative (@code{previous-completion}).
 
diff --git a/etc/NEWS b/etc/NEWS
index d163c18871..1541b74a3b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -444,8 +444,8 @@ major mode.
 
 ** Completion List Mode
 New key bindings have been added: 'n' and 'p' to navigate completions,
-and 'M-g' to switch to the minibuffer, and you can also switch back
-to the completion list buffer with 'M-g'.
+and 'M-g M-c' to switch to the minibuffer, and you can also switch back
+to the completion list buffer with 'M-g M-c'.
 
 ** Benchmark
 *** New function 'benchmark-call' to measure the execution time of a function.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 36fb8e72c1..ec21b7b93b 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2603,7 +2603,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)
+    (define-key map "\M-g\M-c"  'switch-to-completions)
     map)
   "Local keymap for minibuffer input with completion.")
 
diff --git a/lisp/simple.el b/lisp/simple.el
index b3470ac7b0..8849919360 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1661,6 +1661,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\M-c" 'read-expression-switch-to-completions)
     (set-keymap-parent m minibuffer-local-map)
     m))
 
@@ -8848,7 +8849,7 @@ completion-list-mode-map
     (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)
+    (define-key map "\M-g\M-c" 'switch-to-minibuffer)
     map)
   "Local map for completion list buffers.")
 
@@ -9138,6 +9139,12 @@ switch-to-completions
       (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)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-05-25  8:34                           ` Gregory Heytings
@ 2021-05-25  8:40                             ` Lars Ingebrigtsen
  2021-05-25  8:42                               ` Gregory Heytings
  0 siblings, 1 reply; 33+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-25  8:40 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: 47699

Gregory Heytings <gregory@heytings.org> writes:

> Hmmm...  Why did you remove "read-expression-switch-to-completions"
> from the patch?

Did I?

> I know that you can, in vanilla Emacs, achieve the
> same effect with TAB TAB C-- C-x o, which is I think too complicated.
> Patch attached, against the current trunk.

Thanks; applied.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-05-25  8:40                             ` Lars Ingebrigtsen
@ 2021-05-25  8:42                               ` Gregory Heytings
  0 siblings, 0 replies; 33+ messages in thread
From: Gregory Heytings @ 2021-05-25  8:42 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 47699


>> I know that you can, in vanilla Emacs, achieve the same effect with TAB 
>> TAB C-- C-x o, which is I think too complicated. Patch attached, 
>> against the current trunk.
>
> Thanks; applied.
>

Thanks!





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-05-25  4:39                     ` Lars Ingebrigtsen
  2021-05-25  7:32                       ` Gregory Heytings
@ 2021-05-25 12:31                       ` Basil L. Contovounesios
  2021-05-25 19:22                         ` Lars Ingebrigtsen
  2021-05-25 19:25                         ` Gregory Heytings
  1 sibling, 2 replies; 33+ messages in thread
From: Basil L. Contovounesios @ 2021-05-25 12:31 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Gregory Heytings, 47699

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Gregory Heytings <gregory@heytings.org> writes:
>
>> Thanks.  Here is the updated patch.  I tested it with minibuffer-only
>> frames, and it seems to work.
>>
>> Are you sure that it's okay to rebind M-c in
>> minibuffer-local-completion-map?  It's a good mnemonic for
>> "completion", but it hides the capitalize-word binding, that users
>> might possibly want to use there (I don't, it's only when thinking
>> about this patch that I realized this).
>>
>> Another option would be M-g, which would not hide anything that is
>> possibly useful in the minibuffer, and is still a mnemonic of "goto".
>
> Thanks; applied to Emacs 28.

Thanks, but test/lisp/help-tests.el also needs updating:

  Test help-tests-substitute-command-keys/keymaps condition:
      (ert-test-failed
       ((should
         (equal
          (substitute-command-keys orig)
          result))
        :form
        (equal
         #("key             binding..." ...)
         "key             binding...")
        :value nil :explanation
        (arrays-of-different-length 715 688 ... first-mismatch-at 495)))
     FAILED  16/24  help-tests-substitute-command-keys/keymaps (0.000349 sec)

-- 
Basil





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-05-25 12:31                       ` Basil L. Contovounesios
@ 2021-05-25 19:22                         ` Lars Ingebrigtsen
  2021-05-25 19:25                         ` Gregory Heytings
  1 sibling, 0 replies; 33+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-25 19:22 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Gregory Heytings, 47699

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> Thanks, but test/lisp/help-tests.el also needs updating:

Yup; fixed now.  (I'm not quite sure that test is very helpful...)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  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
  1 sibling, 1 reply; 33+ messages in thread
From: Gregory Heytings @ 2021-05-25 19:25 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Lars Ingebrigtsen, 47699

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


>
> Thanks, but test/lisp/help-tests.el also needs updating:
>

Whoops, yes, indeed.  Patch attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-diff; name=Fix-test-in-help-tests.patch, Size: 1135 bytes --]

From e3ae297166ef042c45225a4247321b438da91bbe Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Tue, 25 May 2021 19:22:03 +0000
Subject: [PATCH] Fix test in help-tests

* test/lisp/help-tests.el
(help-tests-substitute-command-keys/keymaps):
Add M-g M-c to the keymap.  This fixes the failed test because of
commit ce2de3b50a.
---
 test/lisp/help-tests.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test/lisp/help-tests.el b/test/lisp/help-tests.el
index b2fec5c1bd..871417da3d 100644
--- a/test/lisp/help-tests.el
+++ b/test/lisp/help-tests.el
@@ -110,14 +110,19 @@ help-tests-substitute-command-keys/keymaps
 <prior>		switch-to-completions
 <up>		previous-line-or-history-element
 
+M-g		Prefix Command
 M-v		switch-to-completions
 
+M-g ESC		Prefix Command
+
 M-<		minibuffer-beginning-of-buffer
 M-n		next-history-element
 M-p		previous-history-element
 M-r		previous-matching-history-element
 M-s		next-matching-history-element
 
+M-g M-c		switch-to-completions
+
 ")))
 
 (ert-deftest help-tests-substitute-command-keys/keymap-change ()
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* bug#47699: [PATCH] Improve completion-list-mode-map
  2021-05-25 19:25                         ` Gregory Heytings
@ 2021-05-25 19:27                           ` Gregory Heytings
  0 siblings, 0 replies; 33+ messages in thread
From: Gregory Heytings @ 2021-05-25 19:27 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Lars Ingebrigtsen, 47699


>> Thanks, but test/lisp/help-tests.el also needs updating:
>
> Whoops, yes, indeed.  Patch attached.
>

... but Lars fixed this a few minutes ago ;-)





^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2021-05-25 19:27 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.