Subject: bug#47699: [PATCH] Improve completion-list-mode-map

From: Gregory Heytings <[email-masked]>
Date: Sun, 11 Apr 2021 01:03:56 +0000

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.

From 53dd1bcb56e743452f5bb825f46c60ed19ae72d1 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <[email-masked]>
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